Re: Cannot find symbol variable number?
KyoGaSuki wrote:
By the way...sorry for how messy it looks. If you have trouble reading
it, I can clean it up and repost?
Oh, no problem buddy. Shoot, I can do that for ya.
/**
* @(#)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);
// All I want it to do is to
// print the number that I
// input from the method.
System.out.println(getNumber(num));
}
public static int getNumber(){
// It told me it couldn't find the scanner, so
// I put it here and the error message went away.
Scanner input = new Scanner(System.in);
System.out.print("Enter an integer: ");
// Could this be the problem? I don't know any other
// way to make the user input a variable, though.
int number = input.nextInt();
return number; // ...please return?
}
}