Java ArrayList - Check if list is empty

前端 未结 6 874
小蘑菇
小蘑菇 2020-12-05 13:00

How can I check if a list is empty? If so, the system has to give a message saying List is empty. If not, the system has to give a message saying Li

6条回答
  •  遥遥无期
    2020-12-05 13:03

    As simply as:

    if (numbers.isEmpty()) {...}
    

    Note that a quick look at the documentation would have given you that information.

提交回复
热议问题