-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhelloWorld.java
More file actions
34 lines (32 loc) · 1.01 KB
/
helloWorld.java
File metadata and controls
34 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package helloWorld;
import java.io.*;
class helloWorld {
// Static block. will executed first and only for once throughout the program
static {
System.out.println("inside static block");
}
// initializer block. will be executed before the constructor and every time a object is created as well.
{
System.out.println("inside initializer block");
}
// Instance data member.
int h = 5;
// main method starts
public static void main(String args[]) {
// creating object of helloWorld class.(initializer block will be executed)
helloWorld h = new helloWorld();
System.out.println(h.h);
System.out.println("Hello World Program!!");
System.out.println("Hello Java :)");
// creating object of helloWorld class.(initializer block will be executed)
helloWorld k = new helloWorld();
System.out.println(k.h);
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
try {
k.h = Integer.parseInt(b.readLine());
System.out.println(k.h);
} catch (Exception e) {
System.out.println(e);
}
}
}