
String auto[]=new String[]{"Length: ","Breadth: ","Height: "}; in the above code i can easily input values into my string auto which is a single dimensional array. How do you do this with a two dimensional array? for eg: String auto[][]=new String[][]{"Length: ","Breadth: ","Height: "}{"Length: ","Breadth: ","Height: "};
the above code generates error. please help!

Here is an example that input values to 2 dimensional array. Here we have defined an array of 2 rows and three columns.
import java.util.*;
class TwoD
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.println("Enter array elements: ");
String auto[][]=new String[2][3];
for(int i=0 ; i < auto.length ; i++)
for(int j=0 ; j < auto[i].length ; j++){
auto[i][j] = input.next();
}
for(int i=0 ; i < auto.length ; i++){
System.out.println();
for(int j=0 ; j < auto[i].length ; j++){
System.out.print(auto[i][j]+" ");
}
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.