Thursday, May 3, 2018

TreeMap Collection Example in Java

Presently I am learning collections framework in Java in this sample program I will show you how to use TreeMap. The code is very simple and easy to understand.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.




Sample Program Output


Program Listing

Main.java

package javaapplication1;

import java.util.*;


/**
 *
 * @author : Mr. Jake R. Pomperada, MAED-IT
 * Date : May 3, 2018
 * Thurdsay
 * Barangay Alijis, Bacolod City Negros Occidental Philippines
 * jakerpomperada@yahoo.com and jakerpomperada@gmail.com
 *
 */
public class Main {
    
    public static void main(String[] args) {
       System.out.println("\n\n");
       System.out.println("TreeMap Collection Example in Java");
       System.out.print("\n");
       
      TreeMap <Integer,String>  set = new TreeMap <Integer,String>();
       
       set.put(1,"Jake R. Pomperada");
       set.put(2,"Ma. Junallie F. Pomperada");
       set.put(3,"Jacob Samuel F. Pomperada");
       set.put(4,"Julianna Rae F. Pomperada");
       set.put(5,"Lydia R. Pomperada");
       set.put(6,"Virgilio V. Pomperada");
       
       
       for (Map.Entry m:set.entrySet()) {
           System.out.println(m.getKey() + " " + m.getValue());
       }
       System.out.print("\n\n");
       System.out.println("End of Program");
       System.out.print("\n\n");
    }
       
}





No comments:

Post a Comment