Computers and Technology
Computers and Technology, 13.10.2020 01:01, rama64

JAVA ECLIPSE Write a class named PhoneBookEntry that has fields for a person's name and phone number. The class should have a constructor and appropriate accessor and mutator methods. Then write a program that creates at least five PhoneBookEntry objects and stores them in an ArrayList. use a loop[ to display the contents of each object in the ArrayList.
There this code:
import java. util.*;
public class PhoneBookEntry {
private String name;
private String number;
public PhoneBookEntry(String name, String number) {
this. name=name;
this. number=number;
}
public String getName() {
return name;
}
public void setName(String name) {
this. name = name;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this. number = number;
}
public static void main(String[] args) {
List phoneList = new ArrayList();
phoneList. add(new PhoneBookEntry("John Smith","818.555.1234"));
phoneList. add(new PhoneBookEntry("Jane Brown","818.555.1235"));
phoneList. add(new PhoneBookEntry("Jose Vargas","818.555.1236"));
phoneList. add(new PhoneBookEntry("Armen Avetian","818.555.1237"));
phoneList. add(new PhoneBookEntry("Xin Liu","818.555.1238"));
phoneList. add(new PhoneBookEntry("James White","818.555.1239"));
phoneList. add(new PhoneBookEntry("Julie McGuiness","818.555.1240"));
phoneList. add(new PhoneBookEntry("Juan Ballardos","818.555.1241"));
phoneList. add(new PhoneBookEntry("Arthur London","818.555.1242"));
phoneList. add(new PhoneBookEntry("Ashot Aghajanian","818.555.1243"));
for (PhoneBookEntry entry : phoneList) {
System. out. println(entry. getName()+" "+entry. getNumber());
}
}
}

Gives me this output:
John Smith 818.555.1234
Jane Brown 818.555.1235
Jose Vargas 818.555.1236
Armen Avetian 818.555.1237
Xin Liu 818.555.1238
James White 818.555.1239
Julie McGuiness 818.555.1240
Juan Ballardos 818.555.1241
Arthur London 818.555.1242
Ashot Aghajanian 818.555.1243

I would like to get the output like this:
First Name: John\n
Last Name: Smith\n
Phone Number: 818.555.1234\n
\n
First Name: Jane\n
Last Name: Brown\n
Phone Number: 818.555.1235\n
\n
First Name: Jose\n
Last Name: Vargas\n
Phone Number: 818.555.1236\n
\n
First Name: Armen\n
Last Name: Avetian\n
Phone Number: 818.555.1237\n
\n
First Name: Xin\n
Last Name: Liu\n
Phone Number: 818.555.1238\n
\n
First Name: James\n
Last Name: White\n
Phone Number: 818.555.1239\n
\n
First Name: Julie\n
Last Name: McGuiness\n
Phone Number: 818.555.1240\n
\n
First Name: Juan\n
Last Name: Ballardos\n
Phone Number: 818.555.1241\n
\n
First Name: Arthur\n
Last Name: London\n
Phone Number: 818.555.1242\n
\n
First Name: Ashot\n
Last Name: Aghajanian\n
Phone Number: 818.555.1243\n
\n

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 21:00, jennifer7037
Ulia is planning to attend the same private four-year college her parents attended. she wants to save at least $18,000 in four years to contribute to her college education. which monthly deposit amounts can julia use to achieve her goal? check all that apply.
Answers: 2
image
Computers and Technology, 23.06.2019 18:00, fordkenae
Which is a possible benefit of having a good credit history? having a checking account low interest rate on a car loan high interest rate on a credit card offer bankruptcy
Answers: 1
image
Computers and Technology, 24.06.2019 05:30, MOONCHILDSUGA
If you combine two cells into one, what action are you performing? a.  adding a new row or column      b.  splitting the cells      c.  removing a new row or column      d.  merging the cells
Answers: 2
image
Computers and Technology, 24.06.2019 07:20, djs1002
Ingrid started speaking about her slide presentation. when she clicked to th"third slide, which had just a picture of an elephant, she forgot what she wassupposed to talk about. what could ingrid do to avoid this situation in thefuture? oa. print handouts for her audience. ob. add presenter's notes to each slide. oc. add a video to each slide. od. save her slide presentation to a flash drive
Answers: 2
Do you know the correct answer?
JAVA ECLIPSE Write a class named PhoneBookEntry that has fields for a person's name and phone numbe...

Questions in other subjects:

Konu
History, 03.04.2020 10:53
Konu
Mathematics, 03.04.2020 10:55
Konu
Mathematics, 03.04.2020 10:57
Konu
Mathematics, 03.04.2020 11:05