ArrayList making with String Data Type
import java.util.ArrayList;
public class Main {
public static void main(String[]ar){
//ArrayList in java
//ArrayList main koi limet nahi hota is amin aap no limet Item daal sakty ho
// <>k anda aap data type btasakty ho jisa k is main<String> data type add hy
// sintax ArrayList<data type> aryVriableName = new ArrayList();
ArrayList<String> arrayList = new ArrayList();
//arryList main Value add krna
//is main sirf String add hosakta hy
arrayList.add("rafiq");
arrayList.add("qadeer");
arrayList.add("meera");
arrayList.add("saim");
//rafiq print hoga
System.out.println(arrayList.get(0));
// arrayList sy data/Value delete karna
arrayList.remove(0);
//qadeer print hoga q k yahan tak code sy Value delete hochuka hy
System.out.println(arrayList.get(0));
}
}
Comments
Post a Comment