3:39 pm - Sunday June 25, 2017

Get size of LinkedHashSet using int size()

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

                             The method public int size() displays the number elements present in the linkedhashset.

Example Program


import java.util.LinkedHashSet;

public class LinkedHashSetSize

{

	public static void main(String[] args)

	{

		LinkedHashSet lh = new LinkedHashSet();

		lh.add("Add");

		lh.add("Sub");

		lh.add("Mul");

		lh.add("Div");

		System.out.println("The set is:" + lh);

		int retval = lh.size();

		System.out.println("Size of set = " + retval);

	}
}

Output

    Size of set = 4

   The set is:[Add, Sub, Mul, Div]

BACK

Filed in: Java Examples

Comments are closed.