Last active
August 25, 2019 21:36
-
-
Save takahashi-h5/7c3ea71d8b363791b897f5f0eb635099 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Emp{ | |
private String name; | |
private int age; | |
Emp(String name) { | |
this(10); // thisはコンストラクタの先頭行に書く必要がある | |
this.name = name; | |
} | |
Emp(int age) {// this(10);でこのコンストラクタが呼ばれる | |
this.age = age; | |
} | |
} | |
public class Main { | |
public static void main(String[] args) { | |
Emp emp = new Emp("takahashi"); | |
System.out.println(emp); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment