A SIMPLE EXAMPLE OF ARRAYLIST IN JAVA

 import java.util; 

//(//) this is called single line comment which will ignore that //what you are saying it is a way to tell to the people so that //they can understand the code  like I am making you //understanding 

//import java.util.*; you can write like this 

 public class ArrayListExample1{  

 public static void main(String args[]){  

  ArrayList<String> list = new ArrayList<String>();//Creating arraylist    

      list.add("Mango");//Adding object in arraylist    

      list.add("Apple");    

      list.add("Banana");    

      list.add("Grapes");    

      //Printing the arraylist object   

      System.out.println(list);  

 }  

}  

Comments

Popular posts from this blog

250+ C Programs for Practice

FUNCTION OVERRIDING IN CPP