Skip to content

Commit bc4690e

Browse files
committed
ThisKeyword -> KeywordTest
1 parent 969f40d commit bc4690e

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

core-java/src/main/java/com/baeldung/keyword/KeywordDemo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.baeldung.keyword;
22

33
import com.baeldung.keyword.superkeyword.SuperSub;
4-
import com.baeldung.keyword.thiskeyword.ThisKeyword;
4+
import com.baeldung.keyword.thiskeyword.KeywordTest;
55

66
/**
77
* Created by Gebruiker on 5/14/2018.
88
*/
99
public class KeywordDemo {
1010

1111
public static void main(String[] args) {
12-
ThisKeyword keyword = new ThisKeyword();
12+
KeywordTest keyword = new KeywordTest();
1313

1414
SuperSub child = new SuperSub("message from the child class");
1515
}

core-java/src/main/java/com/baeldung/keyword/thiskeyword/ThisKeyword.java renamed to core-java/src/main/java/com/baeldung/keyword/thiskeyword/KeywordTest.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
package com.baeldung.keyword.thiskeyword;
22

3-
/**
4-
* Created by Gebruiker on 5/14/2018.
5-
*/
6-
public class ThisKeyword {
3+
public class KeywordTest {
74

85
private String name;
96
private int age;
107

11-
public ThisKeyword() {
8+
public KeywordTest() {
129
this("John", 27);
1310
this.printMessage();
1411
printInstance(this);
1512
}
1613

17-
public ThisKeyword(String name, int age) {
14+
public KeywordTest(String name, int age) {
1815
this.name = name;
1916
this.age = age;
2017
}
@@ -23,11 +20,11 @@ public void printMessage() {
2320
System.out.println("invoked by this");
2421
}
2522

26-
public void printInstance(ThisKeyword thisKeyword) {
23+
public void printInstance(KeywordTest thisKeyword) {
2724
System.out.println(thisKeyword);
2825
}
2926

30-
public ThisKeyword getCurrentInstance() {
27+
public KeywordTest getCurrentInstance() {
3128
return this;
3229
}
3330

@@ -36,15 +33,15 @@ class ThisInnerClass {
3633
boolean isInnerClass = true;
3734

3835
public ThisInnerClass() {
39-
ThisKeyword thisKeyword = ThisKeyword.this;
40-
String outerString = ThisKeyword.this.name;
36+
KeywordTest thisKeyword = KeywordTest.this;
37+
String outerString = KeywordTest.this.name;
4138
System.out.println(this.isInnerClass);
4239
}
4340
}
4441

4542
@Override
4643
public String toString() {
47-
return "ThisKeyword{" +
44+
return "KeywordTest{" +
4845
"name='" + name + '\'' +
4946
", age=" + age +
5047
'}';

0 commit comments

Comments
 (0)