Extend a java class from one file in another java file

前端 未结 4 1185
心在旅途
心在旅途 2020-12-07 13:21

How can I include one java file into another java file?

For example: If I have 2 java file one is called Person.java and one is called Student.ja

4条回答
  •  粉色の甜心
    2020-12-07 13:53

    You don't.

    If you want to extend Person with Student, just do:

    public class Student extends Person
    {
    }
    

    And make sure, when you compile both classes, one can find the other one.

    What IDE are you using?

提交回复
热议问题