New to Eclipse and java [message #137264] |
Tue, 14 February 2006 14:02 |
Eclipse User |
|
|
|
Originally posted by: david_pop12.yahoo.com
This is the First program I tried to run Eclipse 3.1 software,
Unfortunately I could not run it.
I think, I have a problem with this (System.out.printf( "Sum is %d\n",
sum);)and also I have problem using import (java.util.Scanner;)
Plese tell me how to resolve problem. The program and out put is
// Addition program that displays the sum of two numbers
import java.util.Scanner;
public class Addition {
public static void main(String[] args) {
//main method begins execution of java application
Scanner input = new Scanner( System.in );
int number1;
int number2;
int sum;
System.out.print("Enter first integer");
number1 = input.nextInt();
System.out.print( "Inter Second Integer");
sum = number1 + number2;
System.out.printf( "Sum is %d\n", sum);
}
}
Out put is the following
Exception in thread "main" java.lang.Error: Unresolved compilation
problem:
The method printf(String, Object[]) in the type PrintStream is not
applicable for the arguments (String, int)
at Addition.main(Addition.java:24)
|
|
|
|
|
Re: New to Eclipse and java [message #137422 is a reply to message #137264] |
Tue, 14 February 2006 17:53 |
Randy D. Smith Messages: 394 Registered: July 2009 |
Senior Member |
|
|
After that brief diversion into bringing everyone up to speed on the
"advances" of Java 5...
Sounds like your Eclipse is not actually enabling the Java 5
capabilities. How about going Help => About Eclipse SDK => Configuration
Details, then scroll down and tell us the java.runtime.name and
java.runtime.version.
Assuming all is well there (you're actually using Java 5... I don't know
how many people I've seen install Java 5 but not actually be running
it... Eclipse doesn't "magically" know it's there... it has to be on the
path at start-up or specified on the -vm line or in the preferences), go
to Window => Preferences... => Java => Compiler and tell us what the JDK
Compliance, Compiler compliance level says (should be 5.0).
5.0 is required for Scanner and C-like printf.
--
RDS
david wrote:
> This is the First program I tried to run Eclipse 3.1 software,
> Unfortunately I could not run it.
> I think, I have a problem with this (System.out.printf( "Sum is %d\n",
> sum);)and also I have problem using import (java.util.Scanner;)
>
> Plese tell me how to resolve problem. The program and out put is
>
>
> // Addition program that displays the sum of two numbers
>
> import java.util.Scanner;
>
> public class Addition {
>
>
> public static void main(String[] args) {
> //main method begins execution of java application
> Scanner input = new Scanner( System.in );
>
> int number1;
> int number2;
> int sum;
>
> System.out.print("Enter first integer");
> number1 = input.nextInt();
> System.out.print( "Inter Second Integer");
>
> sum = number1 + number2;
>
> System.out.printf( "Sum is %d\n", sum);
>
>
> }
>
> }
>
>
> Out put is the following
>
> Exception in thread "main" java.lang.Error: Unresolved compilation
> problem: The method printf(String, Object[]) in the type PrintStream
> is not applicable for the arguments (String, int)
>
> at Addition.main(Addition.java:24)
>
>
>
|
|
|
Re: New to Eclipse and java [message #137640 is a reply to message #137332] |
Wed, 15 February 2006 17:23 |
Eclipse User |
|
|
|
Originally posted by: a.b.com
Very Sorry. That's the second time I have been caught out by that. I
happen to be one of those who subscribe to the heretical view that 1.4 is
good enough, and 1.5 breaks too many eggs. This may be one of them.
|
|
|
Powered by
FUDForum. Page generated in 0.08116 seconds