This is a beginner's coding question.

Asked 2 years ago, Updated 2 years ago, 18 views

package ex03;

public class Student extends Person {

public int number;

public Student(String name, int age, int number) {

    this.number=number;
}


public static void main(String[] args) {


    Student stu1 = new Student ("Jonghak Yoon", 13,20140112);



    System.out.println(stu1.getName());
    System.out.println(stu1.getage());
    System.out.println(stu1.number());

}

}

It's good to inherit the name and age from person, but I want to add the number inside and pull it together, but the method number is not defined in the bottom output of stu1.number... What's the problem? I've set up the get set and pulled it out. It's going well. But I wanted to do it without getting set...

java

2022-09-21 14:19

1 Answers

If you want to do it without the set set below, I think it's not the bottom number(), but the number


2022-09-21 14:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.