Calling a method inside another method in same class

前端 未结 5 806
北海茫月
北海茫月 2020-11-29 03:25

In page 428 (the chapter about Type Information) of his \"Thinking In Java, 4th Ed.\", Bruce Eckel has the following example:

public class Staff extends Arra         


        
5条回答
  •  [愿得一人]
    2020-11-29 04:00

    The add method that takes a String and a Person is calling a different add method that takes a Position. The one that takes Position is inherited from the ArrayList class.

    Since your class Staff extends ArrayList, it automatically has the add(Position) method. The new add(String, Person) method is one that was written particularly for the Staff class.

提交回复
热议问题