Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to work with Multidimensional arraylist?
    primarykey
    data
    text
    <p>Hey guys sorry i'm a noob at java but im trying to make something and i need a multidimensional array list. It must be implemented into the following code: </p> <pre><code>public static void OpenFile() { ArrayList&lt;ArrayList&lt;String&gt;&gt; array = new ArrayList&lt;ArrayList&lt;String&gt;&gt;(); int retrival = chooser.showOpenDialog(null); if (retrival == JFileChooser.APPROVE_OPTION) { try (BufferedReader br = new BufferedReader(new FileReader( chooser.getSelectedFile()))) { String sCurrentLine; while ((sCurrentLine = br.readLine()) != null) { if (sCurrentLine.equals("")) { continue; } else if (sCurrentLine.startsWith("Question")) { System.out.println(sCurrentLine.split(":")[1]); //add to [0] in array ArrayList } else if (sCurrentLine.startsWith("Answer")) { System.out.println(sCurrentLine.split(":")[1]); //add to [1] in array ArrayList } else if (sCurrentLine.startsWith("Category")) { System.out.println(sCurrentLine.split(":")[1]); //add to [2] in array ArrayList } else if (sCurrentLine.startsWith("Essay")) { System.out.println(sCurrentLine.split(":")[1]); //add to [3] in array ArrayList } } } catch (Exception ex) { ex.printStackTrace(); } } } </code></pre> <p>All the [1] index's of the strings i split need to go into a multidimesional array in this order: question, answer, category, essay.<br> So i am currently using a normal multidimensional array but you cant change the values of it easily. What i want my multidimensional arraylist to look like is this:</p> <p>MultiDimensional ArrayList</p> <ul> <li>[0]: questions(it may be over 100 of them.) </li> <li>[1] answers(it may be over 100 of them.)</li> <li>[2] category(it may be over 100 of them.)</li> <li>[3] essay(it may be over 100 of them.)</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload