Java References - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript Java References - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Thursday, March 14, 2019

Java References


Java References

üAn reference variable holds the memory address.
üIt is similar to the pointer.
üKey difference- cannot manipulate as pointer It point any arbitrary memory location or it cannot be manipulate like an integer.

The null Reference

üAn object reference variable that does not currently point 
to an object is called a null reference.
üThe reserved word null can be used to explicitly set a null 
reference:
       name = null;
üAn object reference variable declared at the class level (an 
instance variable) is automatically initialized to null
üThe programmer must carefully ensure that an object reference 
variable refers to a valid object before it is used.

Instance variables 


üDefault initialization

üIf the variable is within a method, Java does 

NOT initialize it.

üIf the variable is within a class, Java 

initializes it as follows:

üNumeric instance variables initialized to 0.

üLogical instance variables initialized to false.

üObject instance variables initialized to null.

No comments:

Post a Comment

Post Top Ad