Saturday, 16 June 2018

Pullareddy janapana java code

Pullareddy janapana java code with output


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javasample;
import java.util.*;
/**
 *
 * @author rajesh kumar shukla
 */
public class mySortHashtable {
   public static void main(String[] args) {
         // Create and populate hashtable
         Hashtable ht = new Hashtable();
         ht.put("abc",new Double(3445.23));
         ht.put("xyz",new Double(2333.56));
         ht.put("pqr",new Double(3900.88));
         ht.put("mno",new Double(2449.00));
        
         // Sort hashtable.
         Vector v = new Vector(ht.keySet());
         Collections.sort(v);
         
         // Display (sorted) hashtable.
             for (Enumeration e = v.elements(); e.hasMoreElements();) {
             String key = (String)e.nextElement();
             System.out.println(key+":"+ht.get(key));
             System.out.println();
         }
     }
}


mno:2449.0

pqr:3900.88

xyz:2333.56

0 comments:

Post a Comment