I have an array with several elements String[] names = {"Jeremy", "Aude", "David"};
I would like to use the method .substring() to extract the index 1 and 2 namely the elements Aude and David then I want to concatenate the element Jeremy also.
Here is the result that I want to get : Aude, David, Jeremy
Do you have an idea to manipualte the elements ?
Here is my code
ArrayList<String> myList = new ArrayList<>();
String[] names = {"Jeremy", "Aude", "David"};
String x = "";
for(int i = 0; i<names.length; i++){
myList.add(names[i]);
System.out.print(myList.get(i) + " ");
}
x = names.substring(1,2);
Arrays.sort...substring()have to do with this? The method is for extracting part of a string. What you want is simple array lookup by index, and has nothing whatsoever to do withsubstring.