Note that there are some explanatory texts on larger screens.

plurals
  1. POcreate a class to model a list
    primarykey
    data
    text
    <p>I have a class named <code>Person</code>.This class represents (as the name says) a Person. Now I have to create a class <code>PhoneBook</code> to represent a list of <code>Person</code>s. How can I do this? I don't understand what means "create a class to represent a list".</p> <pre><code>import java.util.*; public class Person { private String surname; private String name; private String title; private String mail_addr; private String company; private String position; private int homephone; private int officephone; private int cellphone; private Collection&lt;OtherPhoneBook&gt; otherphonebooklist; public Person(String surname,String name,String title,String mail_addr,String company,String position){ this.surname=surname; this.name=name; this.title=title; this.mail_addr=mail_addr; this.company=company; this.position=position; otherphonebooklist=new ArrayList&lt;OtherPhoneBook&gt;(); } public String getSurname(){ return surname; } public String getName(){ return name; } public String getTitle(){ return title; } public String getMailAddr(){ return company; } public String getCompany(){ return position; } public void setHomePhone(int hp){ homephone=hp; } public void setOfficePhone(int op){ officephone=op; } public void setCellPhone(int cp){ cellphone=cp; } public int getHomePhone(){ return homephone; } public int getOfficePhone(){ return officephone; } public int getCellPhone(){ return cellphone; } public Collection&lt;OtherPhoneBook&gt; getOtherPhoneBook(){ return otherphonebooklist; } public String toString(){ String temp=""; temp+="\nSurname: "+surname; temp+="\nName: "+name; temp+="\nTitle: "+title; temp+="\nMail Address: "+mail_addr; temp+="\nCompany: "+company; temp+="\nPosition: "+position; return temp; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload