본문 바로가기

Java

(36)
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..
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); } } -----------------------------------------------------------------------..
IBM Thread and Monitor Dump Analyzer java 를 구동하기 위해서는 기본적으로 jvm 이 필요하다. java 의 장점은 가비지 컬렉터가 메모리 관리를 하기 때문에 따로 신경쓰지 않아도 되는 것이다. 하지만, 가비지 컬렉터가 만능은 아니다. 메모리 할당이 부족할 수도 있고, 잘못된 코딩으로 인하여 사용되는 자원이 점점 늘어날 수도 있다. 이럴경우 core 파일이 발생하거나 heapdump 가 발생할 수 있다. 하지만 해당 파일만 가지고 내용을 그냥 보기에는 무리가 있으므로 해당 파일을 분석할 수 있는 툴을 돌려야 한다. heapdump 의 경우 그 크기가 매우크기 때문에 분석툴을 돌리기가 힘들다. 물론 요즘은 컴퓨터 사양이 매우 좋아져서 별 무리가 없을수도 있다. ㅡㅡ;; 이번에 소개할 툴은 javacore 를 분석할 수 있는 툴이다. ibm..
Using the Google Plugin for Eclipse Installing the Google Plugin for Eclipse You can install the Google Plugin for Eclipse using the Software Update feature of Eclipse. To install the plugin, using Eclipse 3.4 (Ganymede): Select the Help menu > Software Updates... The "Software Updates and Add-ons" window opens. Select the Available Software tab. Click the Add Site... button. The "Add Site" window opens. For "Location," enter the ..