SHARE
TWEET

Untitled

a guest May 22nd, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class SampleSuper {
  2.  
  3.     public static void main(String[] args) {
  4.         // TODO 自動生成されたメソッド・スタブ
  5.         Sub1 obj = new Sub1("test",12);
  6.         obj.getName();
  7.     }
  8. }
  9.  
  10. class Super1 {
  11.     private String name;
  12.     private int age;
  13.     Super1(String name, int age) {
  14.         this.name = name;
  15.         this.age = age;
  16.         System.out.println("Super コンストラクタ");
  17.     }
  18.     Super1(){}
  19.  
  20.  
  21.     public String getName() {
  22.         return name;
  23.     }
  24.     public void setName(String name) {
  25.         this.name = name;
  26.     }
  27.     public int getAge() {
  28.         return age;
  29.     }
  30.     public void setAge(int age) {
  31.         this.age = age;
  32.     }
  33.  
  34. }
  35.  
  36. class Sub1 extends Super1{
  37.     Sub1(String name, int age) {
  38.         super(name,age);
  39.         System.out.println("sub コンストラクタ");
  40.     }
  41.     Sub1() {}
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top