This is a simple code that focuses on the problem so I can apply this to the actual program.
The first class has the array. The second I want it to print array elements to the scanner. This code gives me a null pointer exception
. I tried using an int instead of int array but still got the same exception. How can I fix this?
public class passthrough{
public void main(String[] args){
PassTry k = new PassTry();
System.out.println(k.pass);
System.out.println(k.her);
}
}//class
public class PassTry{
public int[] pass;
public int her;
public PassTry(){
her = 2;
pass = new int[]{4, 5, 6, 2};
}//constructor
public int res(){
return this.her;
}//res method
}//class