본문 바로가기

Java/__Base

(24)
Synchronization Wrappers http://doc.ddart.net/java/tutorial/collections/implementations/wrapper.html public static Collection synchronizedCollection(Collection c); public static Set synchronizedSet(Set s); public static List synchronizedList(List list); public static Map synchronizedMap(Map m); public static SortedSet synchronizedSortedSet(SortedSet s); public static SortedMap synchronizedSortedMap(SortedMap m); List li..
equalsIgnoreCase() equal() 과 equalsIgnoreCase() 차이 equal은 문자열을 비교를 위해서 쓰인다. 물론 equalsIgnoreCase() 문자열 비교다. 하지만 크게 두가지 차이를 보인다. 첫째 비교시점시 글자길이를 먼저비교한다. 둘째 equalsIgnoreCase() 는 대소문자를 비교하지않는다. 첫번째 이유로 성능면에서는 equalsIgnoreCase() 가 더 빠르다. 하지만 둘중 어떤것을 사용할지는 개발자에 선택으로 사용하면 된다.
java1.5 셈플 java5 로 넘어오면서 많이 바꼈는데 가장 맘에드는건 저너릭스와 enum 타입이 생긴것이다. annotation 은 어떤곳에 써야할지 아직은 감이 안잡힌다. 1. static 멤버 import 하기 - static import 를 사용하면 클래스명을 안쓰고 static 멤버변수와 static 메소드에 접근할수 있다. import static java.lang.Math.*; public class StaticImportTest { public static void main(String args[]) { double y = sin(1.2); System.out.println("SIN(1.2) : " + y); System.out.println("PI : " + PI); } } 2. Eunumerated 타..
[JAVA1.5] JDK 1.5 Sample Code 원문 : http://blog.naver.com/sj99yang/140002147454 JDK 1.5 has some very useful enhancements.  Thanks to Josh Bloch of Sun Microsystems for helpful hints.Early Access: there is an interactive version of this page here where you can post your code fragments to the community at large.--------------------------------------------------------------------------------------1.AutoboxingJava's distinction ..
Java Programming - Why this warning comes when i use Generics in java1.5 Why this warning comes when i use Generics in java1.5? "The cast fromObject to List is actually checking against the erased type of List" I m getting this warning whenever I am fetching any List from a Map object. headerList = (List)listMap.get("headerList"); Re: Why this warning comes when i use Generics in java1.5? The cast fromObject to List is actually checking against the erased type of Lis..
ThreadPoolExecutor http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html#execute(java.lang.Runnable)ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueueRunnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler) * corePoolSize : Pool의 MIN크기* maximumPoolSize : Pool의 MAX 크기* keepAliveTime : Thread가 Idle이고 현재 ..
Java Semaphore Semaphore import java.util.concurrent.Semaphore; //Solving the mutual exclusion problem using Semaphore class class Process2 extends Thread { private int id; private Semaphore sem; public Process2(int i, Semaphore s) { id = i; sem = s; } private int random(int n) { return (int) Math.round(n * Math.random() - 0.5); } private void busy() { try { sleep(random(500)); } catch (InterruptedException e)..
ThreadpoolExecutor ThreadpoolExecutor 출처: http://programmingexamples.wikidot.com/threadpoolexecutor public class ThreadPoolExecutor extends AbstractExecutorService An ExecutorService that executes each submitted task using one of possibly several pooled threads, normally configured using Executors factory methods. Thread pools address two different problems: they usually provide improved performance when executing..