Results 1 to 7 of 7
- 12-03-2010, 08:00 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 10
- Rep Power
- 0
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);
}
- 12-03-2010, 08:07 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
The println( ... ) method takes one argument at most; you are supplying five of them. Change that to:
and never, ever try to run that didn't compile successfully; the JVM will notice it and throws a runtime error.Java Code:System.out.println(fullNamë+" "+street+" "+city+" "+state+" "+zip);
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-03-2010, 09:11 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 10
- Rep Power
- 0
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!
- 12-04-2010, 07:33 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 12-04-2010, 07:58 AM #5
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
see my comment in your code
ADD: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] }
This is correct
This is no good.Java Code:public class Trial { public Trial() { System.out.println("Is it working?"); } public static void main(String[] args) { Trial trial = new Trial(); } }
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 receivingLast edited by mine0926; 12-04-2010 at 08:24 AM.
- 12-04-2010, 08:30 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 12-04-2010, 08:36 AM #7
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
Similar Threads
-
Exception in thread "main" java.lang.Error: Unresolved compilation problem
By jcen in forum New To JavaReplies: 2Last Post: 11-06-2011, 04:40 PM -
Question about error "Exception in thread "main" java.lang.NoSuchMethodError: main
By ferdzz in forum New To JavaReplies: 5Last Post: 06-22-2010, 03:51 PM -
Runtime error "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
By shantimudigonda in forum New To JavaReplies: 1Last Post: 11-20-2009, 07:58 PM -
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main
By barney in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:10 AM -
Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
By romina in forum New To JavaReplies: 1Last Post: 07-25-2007, 10:55 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks