Os:windows7 x64
Jdk:jdk-8u131-windows-x64
Ide:eclipse Oxygen Release (4.7.0)
The original code
Package Jizuiku.eleven302;public class Javaer {private int age;private String name;public int getnum () {return age;} public void Setnum (int.) {this.age = age;} Public String GetName () {return name;} public void SetName (String name) {this.name = name;} Press ALT + SHIFT + S to press S to appear}
Press the shortcut key ALT + SHIFT + S to appear
Press the S key again to appear
Effect Show
Package Jizuiku.eleven302;public class Javaer {private int age;private String name;public int getnum () {return age;} public void Setnum (int.) {this.age = age;} Public String GetName () {return name;} public void SetName (String name) {this.name = name;} @Overridepublic String toString () {return "Javaer [age=" + Age + ", name=" + name + "]";} Press ALT + SHIFT + S to press S to appear}
Test the ToString method of this class
Package Jizuiku.eleven302;public class Demo {public static void main (string[] args) {System.out.println (New Javaer (). ToString ());}}
Effect Show
Java is good, worth learning.
Eclipse is a free, powerful IDE that you should learn to use.
Eclipse4.7 to override the ToString method in a subclass by using the underlying shortcut key