Java Lec 5
Java Lec 5
• Public static void main (String [] arg) >>> its public because jvm can access it and its static to
enable jvm get anything without create object and its void because it has no return type
• System(class member>>> static).out(object).println()(instance object)
• Wrapper class >> has variable and methods
o Has MIN_VALUE and MAX_VALUE [Intger] corresponding wrapper classes to primitive
o Primitive has only value
o Converting to and from String
o Auto outboxing , Auto in boxing
• Garbage collector >>> release object when no reference refer to this object [str1 = new
String(“hello”)]
• Reference release when scoop ending [String str1;]
• Object always be in heap because its dynamic sized (Large size)
• Reference allocated in stack(limited size) may be in heap(Array)
• Nullpointer exception >>> the line refer to null and you call a method through it you must sure
that you create object
• Pointer contain address direct to memory access while reference doesn’t have address (you
don’t direct access to memory you refer to JVM and JVM has pointers deal with memory)
• Array >>> collection of variables of the same datatype(homogeneous)
• Throw ArrayIndexOutOfBoundsException >>> check size of array
• Array of primitive >>> contain values it self reference in stack
• Array of reference >>> contain reference to values in heap
• Check for equality for String using .equals() >>> compare objects not reference
• == for String compares reference not object
• String objects are immutable (change reference from old to new so the old be without reference
so it release ) >>> String str = new String();
• String pool act as shared memory >>> String str = “welcome ” ;
• Array is zero based index
• Applets >>> small app run within web page
• Applets >>> client side code >>> syntax is checked before running and not uploading without
permission from user
• Applets >>> has no entry point [has lifecycle]>>> calling methods by order[call back method] its
calling by default in specific way