Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

Local Objects
Objects bassically also behave differently when It is declared within a method rather than as instance
variables. When its with instance varibale object references we can got that time its with leaving an
object reference uninitialized,and also that tyme when we chaech the code its not null. But here most imp thing is a null reference is not the same as an uninitialized reference. we have a example where compiler complain abt the following code : 
import java.util.Date;
public class TimeTravel {
public static void main(String [] args) {
Date date;
if (date == null)
System.out.println("date is null");
}
}
 When it is complile we got these type of errors : 
%javac TimeTravel.java
TimeTravel.java:5: Variable date may not have been initialized.
If (date == null)
1 error
       
Posted By: Name:Rajesh Kr URL: Local Objects