programming-examples/java/_Basics/Null Reference.java

34 lines
602 B
Java
Raw Normal View History

2019-11-15 12:59:38 +01:00
Null Reference
import com.ack.learning.examples.account.Account;
public class NullReference {
public static void main( String[] args ) {
// unitialised variables
String x;
Account y;
/**
* this is an error because x is unitialised
if( x == null )
{
}
*/
// initialised variables
String hsbc = null;
Account account = null;
// object arrays are initialised to null
String[] names = new String[5];
for( int i = 0; i < names.length; i++ ) {
System.out.println( names[i] );
}
}
}