Need help: input int from console and pass it into method in different class
- by christophe
i'm a beginner, Need help, Please!!!
I want to read number "a" from console and then store them in variable to use as passing to a different class (different .java file).
How do i code the 2 classes?
thanks
public class PassedInMethod{
private int a; .
public PAssMethod(int a) {
a = a; // TODO: where to get the a?
System.out.println("a was passed in!"+a);
}
public class Mainclass{
public static void main( String args[] ){
Scanner input = new Scanner( System.in );
int a;
System.out.print( "Enter your nember: " );
a = input.nextInt();
PassedInMethod(int a);
}