Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-18-2007, 05:27 PM
Member
 
Join Date: Jul 2007
Posts: 35
silvia is on a distinguished road
My error is: ')' expected
This is my code in AddressBookEntry.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; } }
This is my code in AddressBook:
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); } }
My error is:
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.
Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-18-2007, 05:49 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
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:

Code:
AddressBookEntry ab = new AddressBookEntry(name, address, tel, email);
When you fix this and try to compile, you will see that you get another error: "can not find symbol". This is because you did not define and initialize your parameters (e.g. name) in that constructor. Define and initialize those parameters to fix this error:

Code:
String name = "John";
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Identifier expected error vasu18 New To Java 1 01-01-2008 06:49 PM
Error: ')' expected baltimore New To Java 1 08-07-2007 07:32 AM
Error: <identifier> expected barney AWT / Swing 2 07-31-2007 08:38 AM
Error: '{' expected romina New To Java 1 07-26-2007 10:34 AM
MSG ERROR: : expected Marty New To Java 1 05-31-2007 03:21 AM


All times are GMT +3. The time now is 04:07 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org