How do you check whether the list is empty or not in java?



How do you check whether the list is empty or not in java?..

Answer / Satyendra Kumar Yadav

You can use the `isEmpty()` method to check if a List (in this case, List<T>) is empty. For example:nn```javanList<String> myList = new ArrayList<>();nif (myList.isEmpty()) {n System.out.println("The list is empty.");n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is space character in java?

1 Answers  


What is getkey () in java?

1 Answers  


Why collection is called framework in java?

1 Answers  


How does abstract modifier work?

1 Answers   Wipro,


What does flag mean in java?

1 Answers  


What are the 3 types of loops in java?

1 Answers  


Are true and false keywords?

1 Answers  


how to convert mm/dd/yy to dd/mm/yy using collections in java.

4 Answers   Bosch,


What is a boolean used for?

1 Answers  


What is function and its uses?

1 Answers  


What is numeric function?

1 Answers  


What is the Concept of Encapsulation in OOPS

1 Answers   HCL,


Categories