Results 1 to 5 of 5
Thread: Errors I don't understand
- 04-01-2008, 06:03 PM #1
Member
- Join Date
- Apr 2008
- Posts
- 2
- Rep Power
- 0
Errors I don't understand
Hey i'm creating an insurance application in Netbeans and the class containing the clients details looks like this
:Java Code:package insurancecompany; public class ClientDetails { private String clientID; public Name clientName; private Address clientAddress; private PolicyList clientPolicies; public ClientDetails(String ClientID, Name clientName, Address clientAddress, PolicyList clientPolicies) { this.clientID = id; this.clientName = name; this.clientAddress = address; this.clientPolicies = policies; } public String getID() { return id; } public Name getName() { return name; } public Address getAddress() { return address; } public Policies getPolicies() { return policies; } public String toString(){ return "\tID: " + id + ";\t" + "name: " + name + ";\t" + "address: " + address + ";\t" + "policies: " + policies + ""; } }
I am however getting errors being flagged up for every line except private String clientID.
The error says "cannot find symbol"
Can anyone shed any light on the problem?
Cheers
- 04-01-2008, 07:40 PM #2
Within the package insurancecompany, do the Name, Address and Policies etc, class/type exist ? Make sure they're apart of this package. Post a couple of those source files too if you want.
"cannot find symbol" is the Java way of telling you it can't find the types specified in your source code.Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
- 04-01-2008, 07:48 PM #3
Member
- Join Date
- Apr 2008
- Posts
- 2
- Rep Power
- 0
thanks for the reply.
here are a couple of the other classes
Address
Name:Java Code:package insurancecompany; import java.lang.Comparable; /* * Address.java * * Created on 27 March 2008, 13:59 * * * @author Matthew Butterfant */ public class Address implements Comparable<Address> { private String street; private String towncity; private String postcode; public int compareTo(Address other) { int result; if (street.compareTo(towncity) < 0) result = -1; else if (towncity.compareTo(other.towncity) == 0) result = street.compareTo(other.street); else result = 1; return result; } public String toString(){ return street + " " + towncity + " " + postcode; } }
Thanks :)Java Code:package insurancecompany; import java.util.*; /* * Name.java * * Created on 27 March 2008, 13:59 * * @author Matthew Butterfant */ class Name { private String title; private String initials; private String surname; public String getTitle() { return title; } public String getInitials() { return initials; } public String getSurname() { return surname; } public String toString() { return title + " " + initials + " " + surname; } }
- 04-01-2008, 07:55 PM #4
You might wish to change your Name class access to public.
Everything looks ok syntactically.... unless I missed something. I don't have the capacity to test your code right now as I'm at work and on lunch break. If someone can't solve this for you by the time I get out, I'll have a look at it then.Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
- 04-01-2008, 11:55 PM #5
In ClientDetails, you've mismatched variables all over. You try to return variables in the getters but these do not exist. Compare the variables you're trying to return in your getters to those variables that actually exist at the class's scope. For example: return id; ?? you can't because the proper identifier is clientID, same goes for the constructor.
You can't use the '+' operator in a toString(), thus you to get the same functionality you're wishing to achieve, look into using StringBuilder.
Best of luck, and post back with any further questions.Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? Vote now!
Got a little Capt'n in you? (drink responsibly)
Similar Threads
-
help me need to understand queries
By hossainsadd in forum JDBCReplies: 1Last Post: 05-26-2008, 12:02 AM -
help with these errors
By oceansdepth in forum New To JavaReplies: 3Last Post: 04-16-2008, 04:55 PM -
i don understand this error
By Deon in forum New To JavaReplies: 4Last Post: 01-12-2008, 10:03 AM -
I have 3 errors after compiling
By coco in forum JDBCReplies: 2Last Post: 10-18-2007, 09:32 AM -
Errors in constructor
By ai_2007 in forum Advanced JavaReplies: 0Last Post: 07-01-2007, 05:35 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks