(make space for) arrays • Instantiate (create) arrays • Initialize (give values to) arrays • Out of Bounds Error (remember that computers start counting at zero) • jGRASP IDE and example programs
• The Java language uses both objects and primitive data types to store data Primitive data types are the basic way of storing data (building blocks) Objects are composed of primitive data types
part of the Java language When folks at Sun Microsystems made the Java language, primitive data types were an essential component Note that Java is now owned by Oracle
the classes from Java API (Application Programming Interface), so objects are not part of the Java language See the link from the class web site to the Java API
for objects For example, the substring method String name = new String("Nami"); String firstLetter; firstLetter = name.substring(0,1); //firstLetter is character "N"
used to store the address to an array, but not the array itself Since arrays are objects in Java, you must declare an array variable (which will later contain the address to the location of the array object)
& stores the array object’s address in a variable • The array object itself will contain no addresses, because elements have not been assigned to the array yet
an array with one statement • Syntax DataType [] arrayName = {value0, value1, value2, . . ., valueN-1}; • The size of the array is automatically calculated
= {83.33, 73.56, 91.29, 55.55, 67.02,83.33}; • Double precision floating point is a format for decimal number by the IEEE (Institute of Electrical and Electronics Engineers)
a public variable called length length is not a method! Bug: array.length() Useful in loops for(int i=0;i<examScores.length;i++){ System.out.print(examScores[i]+ ", "); }
links to sites to download the software JDK (Java Development Kit) • Used to compile programs • Also includes JRE (Java Runtime Environment) which is the interpreter used to run programs
Java Coding Standard that should be followed when writing programs The main purpose is to make sure the programs are neat and easy to understand • See the “links” column of the class webpage
Use descriptive and appropriate names for all identifiers (variables, method names, class names, constants, etc.) 2. Comment every 3-7 lines of code 3. Be neat
how to • Initialize an array with a loop • Examples of integer division and modulus Modulus is the remainder of a division • For example: 10/7 = 1 remainder 3 • 27/5 = 5 remainder 2
(make space for) arrays • Instantiate (create) arrays • Initialize (give values to) arrays • Out of Bounds Error (remember that computers start counting at zero) • jGRASP IDE and example programs
1.Do the assignment corresponding to this lecture 2.Download necessary software 3.Email me any questions you may have about the material 4.Turn in the assignment before the due date