+ 6
Is it possible to add n 1D empty arraylists in 3d empty arraylist?
In one of my code , I was getting Runtime Error when I added n number of 1D arraylists to add data into the list nth arraylist . Here's the code with the exact problem. https://code.sololearn.com/cSykxEHznwPD/?ref=app
7 Réponses
+ 16
Siddharth Golecha
Check line no 110,111
+ 14
Siddharth Golecha
I saw that you are taking a lot of input into your program
i think this is easyiest way to taking multiple lin inp
ArrayList<Integer> obj = new ArrayList<>();
Scanner sc = new Scanner(System.in);
while(sc.hasNextInt())
{
obj.add(sc.nextInt());
}
And the talk about the 3D list. you can add 1D list to the 3D list only when you put one 1D in 2D list and insert it in the 3D list.
List<List<List<Integer>>> list = new ArrayList<>();
Here is example
list.add(new ArrayList<List<Integer>>());
I think this is helpful for you;
int arr[][][] =
{
index 0 in 3D array
{
index 0 in 2D array
{
0, inedx 0 in 1D array
1,
2
},
{},
{}
}
{
{},{}{}
}
};
+ 10
ChillPill Sumit Programmer😎😎 , the problem says , There are n number of people sitting in a circle . There are g number of guests who will visit people in m minutes with spending 1 minute with each person . The guests will either go clockwise (C) or Anti Clockwise (A) . The people will remember only those guests who visited them last . We have to tell how many people remember each guest .
+ 6
ChillPill , Can you help me out with this😕?
+ 6
Sumit Programmer😎😎 , I know I have to add 2D list first . I am already did that . The matter is , it is throwing exception
+ 6
Gaurav Agrawal you can suggest some inputs here