Need help: input int from console and pass it into method in different class
        Posted  
        
            by christophe
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by christophe
        
        
        
        Published on 2010-05-31T15:19:46Z
        Indexed on 
            2010/05/31
            15:22 UTC
        
        
        Read the original article
        Hit count: 236
        
java
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);
}
© Stack Overflow or respective owner