Skip to content

Commit 4afea74

Browse files
this and super keyword in Java
1 parent 04d61c7 commit 4afea74

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

47.this_and_super_keyword/cwh1.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class cwh1{
2+
int x;
3+
4+
// getter of x
5+
public int getX(){
6+
return x;
7+
}
8+
9+
// Constructor with a parameter
10+
cwh(int x) {
11+
this.x = x;
12+
}
13+
14+
// Call the constructor
15+
public static void main(String[] args) {
16+
cwh obj1 = new cwh(65);
17+
System.out.println(obj1.getX());
18+
19+
}
20+
}

0 commit comments

Comments
 (0)