Answers for "define list length java"

2

list size in java

Collection<Object> list = new ArrayList<>();
        list.size();
        
        // All collections use size()
        // array use array. length
Posted by: Guest on April-12-2021
0

how to get a list length in java

import java.util.ArrayList;
import java.util.List;
public class Demo {
   public static void main(String[] args) {
      List aList = new ArrayList();
      aList.add("Apple");
      aList.add("Mango");
      aList.add("Guava");
      aList.add("Orange");
      aList.add("Peach");
      System.out.println("The size of the ArrayList is: " + aList.size());
   }
}
Posted by: Guest on September-13-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language