BHUPATHY A P BHUPATHY A P - 4 months ago 26
Java Question

what happens while Creating object for class with main method in java

Whats happens when i create object for class with main method.Can i able to use those instance variables within main method,since they are in same class?

class matrix

int i,j;
int a[10];
Scanner one=new Scanner(;
public static void main(String args[])
matrix obj=new matrix();
System.out.println("Enter the numbers");
obj.create(a); // is it correct to use 'a'(instance variable) inside main() ?

void create(int[] a)
// code


No, because you cannot use non-static variable in static method, change