Java programming double dimensional arrays -
Java programming double dimensional arrays -
my aim here type simple code take in number input user , print simple matrix. code typed seems compile doesn't work during run time! code this:
import java.util.scanner; class arr { public static void main() {scanner in=new scanner(system.in); int a[ ][ ]=new int[2][3]; for(int i=0;i<2;i++) { for(int y=0;y<2;y++) { a[i][y]=in.nextint(); } } for(int i=0;i<2;i++) { for(int y=0;y<2;y++) { system.out.print(a[i][y]); } } } }
at same time suggest solution if transpose matrix inputted user?
you have defined main
method incorrectly. proper main
method signature is
public static void main (string[] args)
that's why compiler not compiling code.
java arrays
Comments
Post a Comment