詳解Javaプログラミング Volume 1 - ハッシュコード
import java.util.Hashtable; public class HashtableTest implements Cloneable { Hashtable flock = new Hashtable(); public Object clone( ){ try{ return super.clone(); } catch (CloneNotSupportedException e) { throw new Error("This should never happen!"); } } public static void main(String[] args){ HashtableTest one = new HashtableTest(); HashtableTest anotherOne = (HashtableTest)one.clone(); System.out.println(one); System.out.println(anotherOne); } }
「なんでPerlじゃないの?」って言う質問は無しです!(笑)(Javaの勉強でちょっと詳解Java プログラミング Volume 1のハッシュテーブルのソースコード(Pg. 200とPg.202)をいじってみた。
本ではSheepクラスだが、上記の場合、HashtableTestとした。