Faced with such a problem as getting data from a sheet. It would seem that everything is simple, but not quite. Look here:
ArrayList<String> a = new ArrayList<>(); a.add("1"); a.add("2"); a.add("3"); ArrayList<String> b = new ArrayList<>(); b.add(a.toString()); String splitStr = b.get(0); System.out.println(splitStr); I get this kind of data:
[1, 2, 3] So the actual question: How to get access to these elements? The result was a two-dimensional array. But I do not understand how to get to him? I tried this:
for(String getSplit : splitStr.split("([),(])")){System.out.println("str "+getSplit);} But square brackets remain.
str [1 str 2 str 3] Ie doing something wrong. Tried through regex
Pattern pat = Pattern.compile("([),(])"); Matcher mat = pat.matcher(splitStr); while(mat.find()) { System.out.println("str "+mat.group()); } I get commas. Are there any standard methods? Not to reinvent the wheel.
In general, it turned out like this:
ArrayList<String> a = new ArrayList<>(); a.add("1"); a.add("2"); a.add("3"); ArrayList<ArrayList> b = new ArrayList<>(); b.add(a); for(int q =0; q < b.size(); q++ ) { for(int t=0; t< a.size(); t++) { System.out.println( b.get(q).get(t)); } } Thank you all for your attention.
ArrayList<ArrayList<String>>- Bohdan Korinnyi