Results 1 to 7 of 7
  1. #1
    erin.ctm is offline Member
    Join Date
    Nov 2010
    Posts
    10
    Rep Power
    0

    Default Exception in thread "main" java.lang.Error: Unresolved compilation problem: at Addr

    Hi,
    i am a novice, taking a Java class required for my degree (doesnt involve programming for a living). I am getting these errors with this class. Any idea why? Thanks in advance!

    1. System.out. line(last line) giving me error to delete the “(“.
    2. Getting this error:
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    at Address.main(Address.java:5)

    package useful;
    import java.io.*;
    import java.util.Scanner;
    public class Address
    {
    public static void main(String[] args)
    {
    Scanner in = new Scanner(System.in); }

    private String fullName;
    private String street;
    private String city;
    private String state;
    private String zip;

    public static final String EOL_STRING =
    System.getProperty("line.separator");
    public static final String SPACE = " ";

    public String getFullName(){ return fullName; }
    public String getStreet(){ return street; }
    public String getCity(){ return city; }
    public String getZip(){ return zip; }
    public String getState(){ return state; }


    public String getFullAddress(){
    return street + city + SPACE + state + SPACE + zip + EOL_STRING;
    }

    public void setFullName(String newFullName){ fullName = newFullName; }
    public void setStreet(String newStreet){ street = newStreet; }
    public void setCity(String newCity){ city = newCity; }
    public void setState(String newState){ state = newState; }
    public void setZip(String newZip){ zip = newZip; }

    System.out.println(fullName, street, city, state, zip);
    }

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,292
    Blog Entries
    7
    Rep Power
    24

    Default

    Quote Originally Posted by erin.ctm View Post
    Hi,
    i am a novice, taking a Java class required for my degree (doesnt involve programming for a living). I am getting these errors with this class. Any idea why? Thanks in advance!

    1. System.out. line(last line) giving me error to delete the “(“.
    2. Getting this error:
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    at Address.main(Address.java:5)
    Java Code:
        System.out.println(fullName, street, city, state, zip);
    The println( ... ) method takes one argument at most; you are supplying five of them. Change that to:

    Java Code:
        System.out.println(fullNamë+" "+street+" "+city+" "+state+" "+zip);
    and never, ever try to run that didn't compile successfully; the JVM will notice it and throws a runtime error.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  3. #3
    erin.ctm is offline Member
    Join Date
    Nov 2010
    Posts
    10
    Rep Power
    0

    Default

    thanks for the fast response! I still get a syntax error, with System.out.println in
    System.out.println(fullName + " " + street + " " + city + " " + state + " " + zip);


    and a Unresolved compilation problem with

    is a Scanner in = new Scanner(System.in);

    I know I'm a novice but it looks like I changed either of these lines, I'd mess them up. Java is confusing sometimes!

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,292
    Blog Entries
    7
    Rep Power
    24

    Default

    Quote Originally Posted by erin.ctm View Post
    thanks for the fast response! I still get a syntax error, with System.out.println in
    System.out.println(fullName + " " + street + " " + city + " " + state + " " + zip);
    What exactly was the compiler trying to tell you? Reading such messages can be usefull.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  5. #5
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    7

    Default

    see my comment in your code
    Java Code:
    import java.io.*;
    import java.util.Scanner;
    public class Address 
    {   public static void main(String[] args) 
        {   Scanner in = new Scanner(System.in); 
        }
    
        private String fullName;
        private String street;
        private String city;
        private String state;
        private String zip;
    
        public static final String EOL_STRING =
        System.getProperty("line.separator");
        public static final String SPACE = " ";
    
        public String getFullName(){ return fullName; }
        public String getStreet(){ return street; }
        public String getCity(){ return city; }
        public String getZip(){ return zip; }
        public String getState(){ return state; }
    
    
        public String getFullAddress(){
        return street + city + SPACE + state + SPACE + zip + EOL_STRING;
        }
    
        public void setFullName(String newFullName){ fullName = newFullName; }
        public void setStreet(String newStreet){ street = newStreet; }
        public void setCity(String newCity){ city = newCity; }
        public void setState(String newState){ state = newState; }
        public void setZip(String newZip){ zip = newZip; }
    
        System.out.println(fullName, street, city, state, zip);// [b]this line is not placed in method or anything.[/b]
    }
    ADD:
    This is correct
    Java Code:
    public class Trial
    {   public Trial()
        {   System.out.println("Is it working?");
        }
        
        public static void main(String[] args)
        {   Trial trial = new Trial();
        }
    }
    This is no good.
    Java Code:
    public class Trial
    {   
        public static void main(String[] args)
        {   Trial trial = new Trial();
        }
        
        System.out.println("Is it working?");
    }


    EDIT #2: I did not try to run it, just want to give you an idea what is the error you are receiving
    Last edited by mine0926; 12-04-2010 at 09:24 AM.

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,292
    Blog Entries
    7
    Rep Power
    24

    Default

    Quote Originally Posted by mine0926 View Post
    Java Code:
    public class Trial
    {   
        public static void main(String[] args)
        {   Trial trial = new Trial();
        }
        
        System.out.println("Is it working?");
    }
    Look where you put that statement: it's outside of the body of the main( ... ) method. Move it between those curly brackets.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  7. #7
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    7

    Default

    Quote Originally Posted by JosAH View Post
    Look where you put that statement: it's outside of the body of the main( ... ) method. Move it between those curly brackets.

    kind regards,

    Jos
    Exactly, that is the thread starter's error. That is what I am trying to point out to OP.

Similar Threads

  1. Replies: 2
    Last Post: 11-06-2011, 05:40 PM
  2. Replies: 5
    Last Post: 06-22-2010, 03:51 PM
  3. Replies: 1
    Last Post: 11-20-2009, 08:58 PM
  4. Replies: 1
    Last Post: 08-07-2007, 07:10 AM
  5. Replies: 1
    Last Post: 07-25-2007, 10:55 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
  •