MIT-Curricular/OOP/Java/Lab/Week7/ExampleQues/Example4.java

29 lines
525 B
Java
Raw Normal View History

class Example4{
static int num;
static String mystr;
//First Static
block static{
System.out.println("Static Block 1");
num = 68;
mystr = "Block1";
}
//Second static
block static{
System.out.println("Static Block 2");
num = 98;
mystr = "Block2";
}
public static void main(String args[]){
System.out.println("Value of num="+num);
}
}
// Error:
// Example4.java:6: error: <identifier> expected
// block static{
// ^