---------------------------------------------------문제
 String word="write.do=my.board.WriteForm";
  int ch=word.indexOf("=");  
  String command=word.substring(0,ch);//write.do
  String classnm=word.substring(ch+1);//my.board.WriteForm  
  System.out.println(command);
  System.out.println(classnm);

 

  //command가 key, classnm이 value로
  //해시맵 hm객체에 추가

  HashMap hm=new HashMap();

  hm.put(command, classnm);

 

----------------------------------------------------문제

  HashSet list=new HashSet();
  list.add("list.do=my.board.ListAction");
  list.add("update.do=my.board.UpdateAction");
  list.add("delete.do=my.board.DeleteAction");
  
  HashMap map=new HashMap();
  // =앞의 문자열은 key값
  // =뒤의 문자열은 value값으로 map에 추가
  
  Iterator iter=list.iterator();
  while(iter.hasNext()){
   String word=(String)iter.next();
   int ch=word.indexOf("=");   
   String command=word.substring(0,ch);
   String classnm=word.substring(ch+1);
   map.put(command, classnm);
   System.out.println(map.get(command));
  }

 

'..열심히 공부하세.. > JAVA 문법' 카테고리의 다른 글

[Vector 예제] Buyer - 반품 refund() 메소드  (0) 2012.06.26
[35] JDBC  (0) 2012.05.15
[34] 제네릭 Generics  (0) 2012.05.08
[33] Java Collections Framework  (0) 2012.05.08
[32] Object 클래스  (0) 2012.05.04

+ Recent posts