The Artima Developer Community
Sponsored Link

Java Buzz Forum
Get Size of Java TreeSet Example

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
instanceof java

Posts: 576
Nickname: instanceof
Registered: Jan, 2015

instanceof java is a java related one.
Get Size of Java TreeSet Example Posted: Mar 8, 2016 10:11 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: Get Size of Java TreeSet Example
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement
1.Basic Java example program get size of treeset


  1. package com.TreeSetExamplePrograms;

  2. public Class TreeSetGetSizeDemo{ 
  3.  
  4. public static void main(String args[]) {
  5. //create TreeSet object
  6.  
  7.  TreeSet<String> treeSet = new TreeSet<String>();
  8.  
  9.    //add elements to TreeSet
  10.     treeSet.add("I");
  11.     treeSet.add("N");
  12.     treeSet.add("S");
  13.     treeSet.add("T");
  14.     treeSet.add("A");
  15.     treeSet.add("N");
  16.     treeSet.add("C");
  17.     treeSet.add("E");
  18.           
  19.     treeSet.add("O");
  20.     treeSet.add("F");
  21.           
  22.     System.out.println(treeSet);
  23.           
  24.    System.out.println("Size of TreeSet  : " + treeSet.size());           
  25.     //remove one element from TreeSet using remove method
  26.  
  27.      treeSet.remove("A");
  28.  
  29.  System.out.println("Size of TreeSet after removal of element A : " + treeSet.size()); 
  30.  System.out.println(treeSet);

  31. }
  32. }


Output:


  1. [A, C, E, F, I, N, O, S, T]
  2. Size of TreeSet  : 9
  3. Size of TreeSet after removal of element A : 8
  4. [C, E, F, I, N, O, S, T]






Read: Get Size of Java TreeSet Example

Topic: Basic java programs Previous Topic   Next Topic Topic: Kids : Food Items_v3

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use