본문 바로가기

Java/__Base

(24)
Java - Queue Example import java.util.Iterator; import java.util.LinkedList; import java.util.Queue; public class QueueExample { public static void main(String[] args) { Queue qe=new LinkedList(); qe.add("b"); qe.add("a"); qe.add("c"); qe.add("e"); qe.add("d"); Iterator it=qe.iterator(); System.out.println("Initial Size of Queue :"+qe.size()); while(it.hasNext()) { String iteratorValue=(String)it.next(); System.out...
Java - Hashtable Example 1. Hashtable example with Enumeration import java.util.Hashtable; import java.util.Enumeration; public class HashTableExample { public static void main(String[] args) { Hashtable hTable=new Hashtable(); //adding or set items in Hashtable by put method key and value pair hTable.put(new Integer(2), "Two"); hTable.put(new Integer(1), "One"); hTable.put(new Integer(4), "Four"); hTable.put(new Intege..
Java - How to find date difference import java.util.Calendar; public class DateDiff { public static void main(String[] args) { Calendar ca1 = Calendar.getInstance(); Calendar ca2 = Calendar.getInstance(); // Set the date for both of the calendar to get difference ca1.set(2008, 07, 27); ca2.set(2009, 05, 15); // Get date in milliseconds long milisecond1 = ca1.getTimeInMillis(); long milisecond2 = ca2.getTimeInMillis(); // Find dat..
Java inheritance extends Program InheritanceParent.java --------------------------------------------------------------------------------- public class InheritanceParent { public String abc=null; public String xyz=null; public void printOutput() { System.out.println("Output of Inheritance :"+abc); System.out.println("Output of Second Inheritance :"+xyz); } } -----------------------------------------------------------------------..
DBCP Example (ManualPoolingDriverExample.java) /* * Copyright 1999-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distribute..
DBCP Example (ManualPoolingDataSourceExample.java) /* * Copyright 1999-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distribute..
DBCP Example (BasicDataSourceExample.java) 프로젝트중에서 우연한 기회에 프레임워크를 사용하지 않는 별도에 내부적으로 돌아가는 프로그램을 개발하기위해서 예전에 사용했던 DS를 테스트 해본다. BasicDataSourceExample /* * Copyright 1999-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless r..
diff Test