From bc4690ee54e4f092c7f61b63fe51efe3aa9d4a40 Mon Sep 17 00:00:00 2001 From: mherbaghinyan Date: Sun, 27 May 2018 10:22:30 +0400 Subject: [PATCH] ThisKeyword -> KeywordTest --- .../com/baeldung/keyword/KeywordDemo.java | 4 ++-- .../{ThisKeyword.java => KeywordTest.java} | 19 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) rename core-java/src/main/java/com/baeldung/keyword/thiskeyword/{ThisKeyword.java => KeywordTest.java} (64%) diff --git a/core-java/src/main/java/com/baeldung/keyword/KeywordDemo.java b/core-java/src/main/java/com/baeldung/keyword/KeywordDemo.java index ba27fe0df6..d98586c233 100644 --- a/core-java/src/main/java/com/baeldung/keyword/KeywordDemo.java +++ b/core-java/src/main/java/com/baeldung/keyword/KeywordDemo.java @@ -1,7 +1,7 @@ package com.baeldung.keyword; import com.baeldung.keyword.superkeyword.SuperSub; -import com.baeldung.keyword.thiskeyword.ThisKeyword; +import com.baeldung.keyword.thiskeyword.KeywordTest; /** * Created by Gebruiker on 5/14/2018. @@ -9,7 +9,7 @@ import com.baeldung.keyword.thiskeyword.ThisKeyword; public class KeywordDemo { public static void main(String[] args) { - ThisKeyword keyword = new ThisKeyword(); + KeywordTest keyword = new KeywordTest(); SuperSub child = new SuperSub("message from the child class"); } diff --git a/core-java/src/main/java/com/baeldung/keyword/thiskeyword/ThisKeyword.java b/core-java/src/main/java/com/baeldung/keyword/thiskeyword/KeywordTest.java similarity index 64% rename from core-java/src/main/java/com/baeldung/keyword/thiskeyword/ThisKeyword.java rename to core-java/src/main/java/com/baeldung/keyword/thiskeyword/KeywordTest.java index 63e881bba2..8c6adcfc50 100644 --- a/core-java/src/main/java/com/baeldung/keyword/thiskeyword/ThisKeyword.java +++ b/core-java/src/main/java/com/baeldung/keyword/thiskeyword/KeywordTest.java @@ -1,20 +1,17 @@ package com.baeldung.keyword.thiskeyword; -/** - * Created by Gebruiker on 5/14/2018. - */ -public class ThisKeyword { +public class KeywordTest { private String name; private int age; - public ThisKeyword() { + public KeywordTest() { this("John", 27); this.printMessage(); printInstance(this); } - public ThisKeyword(String name, int age) { + public KeywordTest(String name, int age) { this.name = name; this.age = age; } @@ -23,11 +20,11 @@ public class ThisKeyword { System.out.println("invoked by this"); } - public void printInstance(ThisKeyword thisKeyword) { + public void printInstance(KeywordTest thisKeyword) { System.out.println(thisKeyword); } - public ThisKeyword getCurrentInstance() { + public KeywordTest getCurrentInstance() { return this; } @@ -36,15 +33,15 @@ public class ThisKeyword { boolean isInnerClass = true; public ThisInnerClass() { - ThisKeyword thisKeyword = ThisKeyword.this; - String outerString = ThisKeyword.this.name; + KeywordTest thisKeyword = KeywordTest.this; + String outerString = KeywordTest.this.name; System.out.println(this.isInnerClass); } } @Override public String toString() { - return "ThisKeyword{" + + return "KeywordTest{" + "name='" + name + '\'' + ", age=" + age + '}';