본문 바로가기

Java/__Base

(24)
The JDBC Connection Pool - BoneCP BoneCP http://jolbox.com/ AboutBoneCP is a fast, free, open-source, Java database connection pool (JDBC Pool) library. If you are familiar with C3P0 and DBCP then you already know what this means. For the rest, this is a library that will manage a database connection for you to get faster database access in your application.
Java - HashSetExample import java.util.*; public class HashSetExample { private static String names[] = { "bob", "hemanth", "hhh", "hero", "shawn", "bob", "mike", "Rick", "rock", "hemanth", "mike", "undertaker" }; public static void main(String args[]) { ArrayList aList; aList = new ArrayList(Arrays.asList(names)); System.out.println("The names elements " + aList); HashSet ref = new HashSet(aList); // create a HashSe..
Java - Iterator Example import java.util.Hashtable; import java.util.Iterator; import java.util.Set; import java.util.Map; public class IteratorExample { public static void main(String[] args) { Hashtable hTable=new Hashtable(); hTable.put(new Integer(2), "Two"); hTable.put(new Integer(1), "One"); hTable.put(new Integer(4), "Four"); hTable.put(new Integer(3), "Three"); Set s =hTable.entrySet(); // Using iterator in has..
Java - Enumeration Example import java.util.Enumeration; import java.util.Vector; public class EnumerationExample { public static void main(String[] args) { Vector vc=new Vector(); vc.add("Two"); vc.add("One"); vc.add("Four"); vc.add("Three"); // Get Enumeration to get value Enumeration em=vc.elements(); while(em.hasMoreElements()) { String value = (String)em.nextElement(); System.out.println("value :"+value); } } } Outpu..
Java - Set Example import java.util.Iterator; import java.util.Set; import java.util.TreeSet; public class SetExample { public static void main(String[] args) { // Set example with implement TreeSet Set s=new TreeSet(); s.add("b"); s.add("a"); s.add("d"); s.add("c"); Iterator it=s.iterator(); while(it.hasNext()) { String value=(String)it.next(); System.out.println("Value :"+value); } } } Output Set Value :a Set Va..
Java - List Example import java.util.Iterator; import java.util.List; import java.util.ArrayList; public class ListExample { public static void main(String[] args) { // List Example implement with ArrayList List ls=new ArrayList(); ls.add("one"); ls.add("Three"); ls.add("two"); ls.add("four"); Iterator it=ls.iterator(); while(it.hasNext()) { String value=(String)it.next(); System.out.println("Value :"+value); } } }..
Java - TreeSet Example import java.util.Iterator; import java.util.TreeSet; public class TreeSetExample { public static void main(String[] args) { // TreeSet return in ordered elements TreeSet ts=new TreeSet(); ts.add("b"); ts.add("a"); ts.add("d"); ts.add("c"); // get element in Iterator Iterator it=ts.iterator(); // get descending order of elements //Iterator it=ts.descendingIterator(); while(it.hasNext()) { String ..
Java - SortedMap Example import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; public class SortedMapExample { public static void main(String[] args) { SortedMap sm=new TreeMap(); sm.put(new Integer(2), "Two"); sm.put(new Integer(1), "One"); sm.put(new Integer(4), "Four"); sm.put(new Integer(3), "Three"); sm.put(new Integer(5), "Five"); Set s=sm.entr..