Please examine the following 2 codes:
1)
class
Test {
transient int maxElements = 100;
public static void main(
String []args){
Test t= new Test();
System.out.println(t.maxElements);
}
}
100 is printed. Why?
2)
class Test {
//transient int maxElements = 100;
public static void main(String []args){
transient int maxElements = 100;
Test t= new Test();
System.out.println(t.maxElements);
}
}
compile error. Any one has any idea? Thanks.