2:29 am - Tuesday March 28, 2017

check whether LinkedList is empty using boolean isEmpty()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

           This tutorial explains how  to check whether  LinkedList is empty using boolean isEmpty() method.

If you pass null value to the element isEmpty() treat that as data.Returns only the boolean result only.

Example

import java.util.LinkedList;
public class CheckElement
{
public static void main(String a[])
{
   LinkedList<String> ll = new LinkedList<String>();
   ll.add("Orange");
   ll.add("Apple");
   ll.add("Grape");
   ll.add("Banana");
   ll.add("karthik");
   System.out.println("The size of linked List  :"+ll.isEmpty());
 }
}

Output

          The size of linked List  :false

BACK

Filed in: Java Examples

Comments are closed.