Skip to content
Snippets Groups Projects
Commit cbbb4ffc authored by VIGNESH VIJAYAKUMAR's avatar VIGNESH VIJAYAKUMAR
Browse files

Upload New File

parent 22ba4a5c
No related branches found
No related tags found
No related merge requests found
import java.util.ArrayList;
import java.util.Collections;
public class ArrayLinked{
public static void main(String[] args){
String[] cc = {"volvo","BMW"};
System.out.println(cc);//this print doesn't work properly
for(String i:cc){
System.out.println(i);
}
ArrayList<String> cars = new ArrayList<String>();
cars.add("Volvo");
cars.add("Audi");
cars.add("Lamborgini");
System.out.println(cars);//this print as like array [elements....]
Collections.sort(cars);
System.out.println("After sorting : "+cars);
System.out.println("at index 1: "+cars.get(1));//return 1st index element
System.out.println("replace index \"1\" with Ferrari");
cars.set(1,"Ferrari");
System.out.println(cars);
System.out.println("Before remove : "+cars.size());
cars.remove(1);//remove element
System.out.println("After remove : "+cars.size());
System.out.println(cars);
cars.clear();
System.out.println("After cars.clear():"+cars);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment