class Outer {
static void m3(){
System.out.println("????????????????? " +x);
x = 20;
}
static void m4(){
System.out.println("How are you ? are you Good ?ddddddddddddddd " +x);
}
static {
System.out.println("Hi Balaji................ ?aaaaaaaaaaaaaaa ");
m3();
}
static {
System.out.println("Hi Balaji................ ?bbbbbbbbbbbbbbb ");
m4();
}
static int x = 10;
static int y = x;
public static void main(String args[]) {
System.out.println("Hi Balaji how are you ? " + y);
}
}
******************************************************************************************************************************************************************
//Execute this and see
Run using
javac Outer.java
java Outer$Inner
*********************************************************************************
In this in place of x in System.out.println("????????????????? " +x);
if you declare it as m ,
System.out.println("????????????????? " +m);
then you will get comiplation error because the jvm sees whether the code is syntacally right or not, not its correctness..
Similarly you can change the method m3() as say m3333() and you will see that you will get
compile error...
Whereas runtime exception or error is checking for the correctness of the code when the program actually runs
*********************************************************************************
static void m3(){
System.out.println("????????????????? " +x);
x = 20;
}
static void m4(){
System.out.println("How are you ? are you Good ?ddddddddddddddd " +x);
}
static {
System.out.println("Hi Balaji................ ?aaaaaaaaaaaaaaa ");
m3();
}
static {
System.out.println("Hi Balaji................ ?bbbbbbbbbbbbbbb ");
m4();
}
static int x = 10;
static int y = x;
public static void main(String args[]) {
System.out.println("Hi Balaji how are you ? " + y);
}
}
******************************************************************************************************************************************************************
//Execute this and see
Run using
javac Outer.java
java Outer$Inner
*********************************************************************************
In this in place of x in System.out.println("????????????????? " +x);
if you declare it as m ,
System.out.println("????????????????? " +m);
then you will get comiplation error because the jvm sees whether the code is syntacally right or not, not its correctness..
Similarly you can change the method m3() as say m3333() and you will see that you will get
compile error...
Whereas runtime exception or error is checking for the correctness of the code when the program actually runs
*********************************************************************************
No comments:
Post a Comment