Results 1 to 5 of 5
  1. #1
    MattyB is offline Member
    Join Date
    Apr 2008
    Posts
    2
    Rep Power
    0

    Exclamation 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

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    9

    Default

    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)

  3. #3
    MattyB is offline Member
    Join Date
    Apr 2008
    Posts
    2
    Rep Power
    0

    Default

    thanks for the reply.

    here are a couple of the other classes

    Address
    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;
        }
    
       
        
    }
    Name:
    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;
         }
            
      }
    Thanks :)

  4. #4
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    9

    Default

    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)

  5. #5
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    9

    Default

    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

  1. help me need to understand queries
    By hossainsadd in forum JDBC
    Replies: 1
    Last Post: 05-26-2008, 01:02 AM
  2. help with these errors
    By oceansdepth in forum New To Java
    Replies: 3
    Last Post: 04-16-2008, 05:55 PM
  3. i don understand this error
    By Deon in forum New To Java
    Replies: 4
    Last Post: 01-12-2008, 11:03 AM
  4. I have 3 errors after compiling
    By coco in forum JDBC
    Replies: 2
    Last Post: 10-18-2007, 10:32 AM
  5. Errors in constructor
    By ai_2007 in forum Advanced Java
    Replies: 0
    Last Post: 07-01-2007, 06:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •