how to add string to array in java
ArrayListar = new ArrayList (); String s1 ="Test1"; String s2 ="Test2"; String s3 ="Test3"; ar.add(s1); ar.add(s2); ar.add(s3); String s4 ="Test4"; ar.add(s4);
Here is what the above code is Doing:
1. Create an ArrayList of type String
2. Create 3 String variables
3. Add the 3 String variables to the ArrayList
4. Create another String variable
5. Add the new String variable to the ArrayList