ArrayList in Java
•
Java
ArrayList<String> veri1 = new ArrayList<String>();
ArrayList<String> veri1 = new ArrayList<String>(); String[] veri2 = {"Fatih","Ferhat","Furkan"};
How to add veri2 to veri1, just like an element? I mean, if I call veri Get (0), which will return veri2
Solution
You should declare the list as a string array list instead of a string list:
List<String[]> veri1 = new ArrayList<String[]>(); String[] veri2 = {"Fatih","Furkan"}; veri1.add(veri2);
Note that it is usually better to declare a list as a list rather than an ArrayList, because you are free to switch to a different list implementation later
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码