Java notes day 2. 1) Arrays An array is an object into which you can put other things. you can put in primitives you can put in objects Declare an array as type[] name ; And the create the array with name = new type[n_of_items]; Access the i'th element as name[i] example2.1 (note overloaded printTheArray method) Note items in an array are numbered from 0 to N-1, and this index number is sometimes called the offset. example2.2. Put objects into an array, get them out! 2) Static Take a close look at a class: public class Student extends Object { static String teacher; //look, it's a class variable. String myName; //look, it's an instance variable public Student (String s){ //look, it's a constructor myName = s; } //look, it's a static (class) method public static void setTeacherName(String s){ teacher = s; } 1. key terms in creating classes/fields static: a static field means there is only one of these for each class. You can set the value of this field even if no instances exist. All instances share this thing. static methods are ones that the class itself can execute. must not directly access instance variables I (personally) think there is a mistake in java's design because static methods can be called either by the class name Student.setTeacherName("bob"); Or, if you have an instance of the class, you can tell the instance to do the same thing: aParticularStudent.setTeacherName("bob"); As far as I know, other languages don't allow instances to execute class methods. Please also note that since teacher is a public static variable, we could access it directly as: Student.teacherTeacherName; instead of using the method setTeacherName. I don't like doing it that way for information hiding reasons. 3) Inheritance and project design. interface--list of methods all subclasses must implement. Any class can adopt this interface, which means a promise to implement its methods. abstract class--methods list, similar in nature to interface, but it cannot be adopted by any class except a subclass. inner classes 4) Using packages If it is a jar file, add the jar file to the CLASSPATH if it is *.class files, add the directory to the CLASSPATH