-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA5.java
More file actions
35 lines (30 loc) · 903 Bytes
/
A5.java
File metadata and controls
35 lines (30 loc) · 903 Bytes
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
35
public class A5 {
public static class Obj {
static int count = 0;
{
System.out.println("Object is created....");
count++;
}
int id;
String name;
Obj(int id, String name) {
this.id = id;
this.name = name;
}
public String toString() {
return "id: " + this.id + " name: " + this.name + " count: " + count;
}
}
public static void main(String[] args) {
Obj shubham = new Obj(1, "shubham");
System.out.println(shubham);
Obj umesh = new Obj(2, "umesh");
System.out.println(umesh);
Obj reetik = new Obj(3, "reetik");
System.out.println(reetik);
Obj krishna = new Obj(4, "krishna");
System.out.println(krishna);
Obj dipesh = new Obj(5, "dipesh");
System.out.println(dipesh);
}
}