21 lines
418 B
Java
21 lines
418 B
Java
|
class Example3 {
|
||
|
|
||
|
static int num;
|
||
|
|
||
|
static String mystr;
|
||
|
|
||
|
static {
|
||
|
num = 97;
|
||
|
mystr = "Static keyword in Java";
|
||
|
}
|
||
|
|
||
|
public static void main(String args[]) {
|
||
|
System.out.println("Value of num=" + num);
|
||
|
System.out.println("Value of mystr=" + mystr);
|
||
|
}
|
||
|
}
|
||
|
// Last } wasn't included, but I added it.
|
||
|
// Output:
|
||
|
// Value of num=97
|
||
|
// Value of mystr=Static keyword in Java
|