본문 바로가기

나 어제 배웠다/JAVA[Tip]

(7)
정규식 표현 1. 정규 표현식(Regular Expression!)이란 문자열에서 어떤 패턴을 찾기 위해 사용되는 표현식 - 날짜 형식 (yyyy/mm/dd, yy-mm-dd)이나 E-mail 주소 형식(xxxx@dddd.dd.dd)과 같이 일정한 패턴을 가지고 있는 문자열들을 체크하기 위해 사용 2. 꼭 알아두어야 할 정규 표현식들 1) 정규 표현식들 . 영문자 한 글..
StringTokenizer String arr = "a,b,c"; String str = "b"; StringTokenizer st = new StringToKenizer(arr, ","); if(null != st && st.countTokens() != 0){ String tmp = ""; while(str.hasMoreTokens()){ tmp = (String)st.nextToken(); if(tmp.equals(str)){ OK break; } } }
Object Array 방법 public class MyAnimalList{ private Animal[] animals = new Animal[5]; private int nextIndex = 0; public void add(Animal a){ animals[nextIndex] = a; nextIndex++; } } public class AnimalTestDrive{ public static void main(String [] args){ MyAnimalList list = new MyAnimalList(); Dog a = new Dog(); Cat c = new Cat(); list.add(a); list.add(c); } } ======================================================..
iBatis IN 구문 구현 방법 where b.SNO in <iterate property="lsno" open="(" close=")" conjunction=","> #lsno[]# </iterate>
예외 처리(Exception) 예외 처리 1.1 예외 처리 정의 예외 처리 (exception handling) 란 무엇인가? 이 질문에 대답하기 전에 `예외란 무엇인가' 라는 문제를 먼저 고려해 보아야 할 것이다. 예외 (exception) 라는 것은 사전적인 의미로 `규칙이나 약속에서 벗어남' 을 의미한다. 프로그래밍 언어에서 예외라는 것은 프로그램이 알고리..
Exception in finally Test import java.lang.System; import java.lang.Exception; class FinallyTest{ public static void main(String[] arg){ String sTmp = "start"; String sTmp1 = "end"; try{ System.out.println("main try"); throw new Exception(); }catch(Exception e){ System.out.println("main catch"); }finally{ if(sTmp.equals("start"))try{throw new Exception();}catch(Exception e){System.out.println("main finally start catch")..
Iterator Design Pattern Sample import java.lang.String; import java.io.File; import java.util.Iterator; import java.util.List; import java.util.LinkedList; import java.util.ArrayList; import java.util.Arrays; class IteratorPattern{ public static void main(String[] args){ String[] tmp = {"test1","test2","test3","test4"}; List<String> l = new ArrayList<String>(Arrays.asList(tmp)); /* List<String> l = new Link..