java_Hashtable 인스턴스
1530 단어 Hashtable
package ming;
import java.util.Hashtable;
class D {
int count;
public D(int count) {
this.count = count;
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == D.class) {
D d = (D) obj;
return this.count == d.count;
}
return false;
}
public int hashCode(){
return this.count;
}
}
class E{
@Override
public boolean equals(Object obj) {
return true;
}
}
public class HashtableTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Hashtable ht = new Hashtable();
ht.put(new D(6000), "java");
ht.put(new D(87563), "C++");
ht.put(new D(1232), new E());
System.out.println(ht);
/* equals true
* Hashtable value
* Hashtable E
* equal , true
*/
System.out.println(ht.containsValue("testing value"));
/*
* D count , equals() true, hashcode
* Hashtable , true
* */
System.out.println(ht.containsValue(new D(6000)));
/*
* key-value
* */
ht.remove(new D(1232));
/*
* key-value
* */
for(Object key:ht.keySet()){
System.out.print(key+"-->");
System.out.print(ht.get(key));
System.out.println();
}
}
}
// key !!!!!!!!!!!!!!!!!!!!!!!!!!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
hive0.13 mapjoin hashtable에서 찾을 수 없는 버그온라인 작업 오류: 이것은 사실mapjoin의 버그입니다.mapjoin은 작은 테이블을 통해hashtable를 생성한 다음distributecache에 넣고, 뒤의task는distributecache를 통해 로컬로 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.