Question: **Java error** (Output error: C:TempJava32bitPhoneBookEntry.java:7: error: missing method body, or declare abstract public static void main(String[] args); ^ Note: C:TempJava32bitPhoneBookEntry.java uses unchecked or unsafe operations.

**Java error**

(Output error:

C:\Temp\Java\32bit\PhoneBookEntry.java:7: error: missing method body, or declare abstract public static void main(String[] args); ^ Note: C:\Temp\Java\32bit\PhoneBookEntry.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error

Tool completed with exit code 1)

It also says(Error: Main method not found in class PhoneBookEntry, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application Press any key to continue . . .)

-The code is completed i googled it and they say its deprecated API

Instructions: Fix the error keeping the format of the code and make sure it runs on textPad

I will tumbs up!

//code

import java.util.*;//for ArrayList class

class PhoneBookEntry{ //PhoneBookEntry Class

private String name;

private String phoneNumber;

PhoneBookEntry(){

this.name = "";

this.phoneNumber = "";

}

//parameterized constructor

PhoneBookEntry(String name,String phoneNumber){

this.name = name;

this.phoneNumber = phoneNumber;

}

//mutator methods.

void setName(String name){

this.name = name;

}

void setPhoneNumber(String phoneNumber){

this.phoneNumber = phoneNumber;

}

//accessor methods.

String getName(){

return this.name;

}

String getPhoneNumber(){

return this.phoneNumber;

}

public String toString(){

return "Name: "+getName()+", PhoneBookEntry: "+getPhoneNumber();

}

}

class Main{//dirver class

public static void main(String[] args) { //main method

PhoneBookEntry pbe1 = new PhoneBookEntry("John","984-894-8888");

PhoneBookEntry pbe2 = new PhoneBookEntry("Ben Affleck","879-849-8498");

PhoneBookEntry pbe3 = new PhoneBookEntry("Leonard","456-798-2341");

PhoneBookEntry pbe4 = new PhoneBookEntry("Mathew","347-146-3248");

PhoneBookEntry pbe5 = new PhoneBookEntry("Christian","541-387-9812");

ArrayList al = new ArrayList();//ArrayList object creation

//adding all the PhoneBookEntry Objects ot ArrayList

al.add(pbe1);

al.add(pbe2);

al.add(pbe3);

al.add(pbe4);

al.add(pbe5);

//looping through the al and printing the content in al

for(int i=0;i

System.out.println(al.get(i));

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!