Results 1 to 2 of 2
Thread: My error is: ')' expected
- 07-18-2007, 04:27 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 35
- Rep Power
- 0
My error is: ')' expected
This is my code in AddressBookEntry.java:
Java Code:public class AddressBookEntry{ private String name; private String address; private String tel; private String email; AddressBookEntry(String name, String address, String tel, String email){ this.name = name; this.address = address; this.tel = tel; this.email = email; } public String getName(){ return name; } public void setName(String n){ name = n; } public String getAddress(){ return address; } public void setAddress(String a){ address = a; } public String getTel(){ return tel; } public void setTel(String t){ tel = t; } public String getEmail(){ return email; } public void setEmail(String e){ email = e; } }
Java Code:public class AddressBook{ private AddressBookEntry[] abe; private final int BOOK_SIZE = 100; private int count; AddressBook(){ abe = new AddressBookEntry[BOOK_SIZE]; count = 0; } public void addEntry(AddressBookEntry abe){ this.abe[count++] = abe; } public void delEntry(String name){ for (int i = 0; i<count; i++){ if(abe[i].getName().equals(name)){ abe[i] = abe[--count]; } } } public void viewAll(){ for(int i = 0; i<count; i++){ System.out.println("Name: " + abe[i].getName()); System.out.println("Address: " + abe[i].getAddress()); System.out.println("Telno: " + abe[i].getTel()); System.out.println("E-mail: " + abe[i].getEmail()); } } public boolean update(String name, String address, String tel, String email){ boolean found = false; for(int i = 0; i<count; i++){ if(abe[i].getName().equals(name)){ abe[i].setAddress(address); abe[i].setTel(tel); abe[i].setEmail(email); } } return found; } public static void main(String[] args){ AddressBook abe = new AddressBook(); AddressBookEntry ab = new AddressBookEntry(String name, String address, String tel, String email); ab.getName(abe); } }
Java Code:Configuration: <Default> C:\Documents and Settings\gen\Desktop\myjavaprogram\AddressBook.java:47: ')' expected AddressBookEntry ab = new AddressBookEntry(String name, String address, String tel, String email); ^ 1 error Process completed.
- 07-18-2007, 04:49 PM #2
You have two errors there.
First of all while calling a method or constructor, you dont write the types of the parameters. So use like this:
Java Code:AddressBookEntry ab = new AddressBookEntry(name, address, tel, email);
Java Code:String name = "John";
Similar Threads
-
Identifier expected error
By vasu18 in forum New To JavaReplies: 1Last Post: 01-01-2008, 05:49 PM -
Error: ')' expected
By baltimore in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:32 AM -
Error: <identifier> expected
By barney in forum AWT / SwingReplies: 2Last Post: 07-31-2007, 07:38 AM -
Error: '{' expected
By romina in forum New To JavaReplies: 1Last Post: 07-26-2007, 09:34 AM -
MSG ERROR: : expected
By Marty in forum New To JavaReplies: 1Last Post: 05-31-2007, 02:21 AM
Bookmarks