Skip to content

Commit 488d5ce

Browse files
author
swetha
committed
converting array to arraylist
1 parent 3ceb4a4 commit 488d5ce

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.tecmax.methodExamples;
2+
3+
4+
import java.lang.reflect.Array;
5+
import java.util.Arrays;
6+
import java.util.List;
7+
8+
public class ArraytoArraylistDemo {
9+
10+
11+
12+
public static void main(String[] args) {
13+
// TODO Auto-generated method stub
14+
String [] sa= {"swetha","madhuri","nandini"};
15+
List<String> abList= Arrays.asList(sa);
16+
System.out.println(abList);
17+
}
18+
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
package com.tecmax.methodExamples;
22

3+
import java.util.ArrayList;
4+
35
public class arraylist {
6+
public static void main(String[] args) {
7+
// TODO Auto-generated method stub
8+
ArrayList<String> a=new ArrayList<String>();
9+
a.add("swetha");
10+
a.add("theja");
11+
a.add("joshna");
12+
a.add("priyanka");
13+
System.out.println(a);
14+
a.add(0,"nandini");
15+
System.out.println(a);
16+
int pos=a.indexOf("madhuri");
17+
String str=a.get(12);
18+
int numberofitems=a.size();
19+
System.out.println("current arraylist position stringvalue size is:"+"\n"+ numberofitems);
20+
a.remove("dileep");
21+
System.out.println(a);
22+
23+
}
24+
425

526
}

0 commit comments

Comments
 (0)