java使某人必须中奖_关于java:我可以让某人验证我的SCJP考试的馆藏

import java.util.*;

import java.lang.*;

class MyItem implements Comparable{

private String name;

MyItem(String n){ name = n; }

public String toString(){return name;}

public String getName(){return name;}

public boolean equals(Object obj){

if(this==obj) return true;

else if(obj==null) return false;

else if(getName() != ((MyItem)obj).getName()) return false;

else return true;

}

public int hashCode(){ return 5; }

public int compareTo(MyItem b){return b.getName().compareTo(getName());}

}

public class MyCollections{

public static void main(String[] args){

MyHashMap.main(args);           System.out.println("HashMap: Hash=Unsorted, Unordered. Map=key/value pair

##

");

MyHashtable.main(args);         System.out.println("Hashtable: Thread Safe. Hash=Unsorted, Unordered. Map=key/value pair

##

");

MyTreeMap.main(args);           System.out.println("TreeMap: Tree=sorted. Map=key/value.

##

");

MyLinkedHashMap.main(args);     System.out.println("LinkedHashMap: Linked=Maintains Insertion Order. Hash=unsorted, unordered. Map=key/value pair.

##

");

MyHashSet.main(args);           System.out.println("HashSet: Hash=Unsorted, Unordered. Set=Unique. Define=equals/hashCode

##

");

MyTreeSet.main(args);           System.out.println("TreeSet: Tree=Sorted. Set=Unique. Define=Comparable/Comparator

##

");

MyLinkedHashSet.main(args);     System.out.println("LinkedHashSet: Liniked=Maintains Insertion Order. Hash=Unsorted. Set=Unique. Define=equals/hashCode

##

");

MyArrayList.main(args);         System.out.println("ArrayList: List=Queue. Maintains insertion order, Allowed duplicates

##

");

MyVector.main(args);            System.out.println("Vector: Thread Safe. ArrayList. Maintains Insertion Order, Allows duplicates

##

");

MyLinkedList.main(args);        System.out.println("LinkedList: Linked=Maintaines Insertion Order. List=Queue. Advanced ArrayList with more methods.

##

");

MyPriorityQueue.main(args);     System.out.println("PriorityQueue: Define=Comparable/comparator

##

");

}

}

class MyHashMap{

public static void main(String[] args){

HashMap c = new HashMap();

MyItem Eight = new MyItem("Eight");

c.put(5, new MyItem("Five")); c.put(1, new MyItem("One")); c.put(8, Eight); c.put(3, new MyItem("Three"));

c.put(4, new MyItem("Four")); c.put(1, new MyItem("1")); c.put(8, Eight); c.put(9, new MyItem("Nine"));

c.remove(3); c.put(7, new MyItem("Seven"));

System.out.println(c);//output?

}

}

class MyHashtable{

public static void main(String[] args){

Hashtable c = new Hashtable();

MyItem Eight = new MyItem("Eight");

c.put(5, new MyItem("Five")); c.put(1, new MyItem("One")); c.put(8, Eight); c.put(3, new MyItem("Three"));

c.put(4, new MyItem("Four")); c.put(1, new MyItem("1")); c.put(8, Eight); c.put(9, new MyItem("Nine"));

c.remove(3); c.put(7, new MyItem("Seven"));

System.out.println(c);//output?

}

}

class MyTreeMap{

public static void main(String[] args){

TreeMap c = new TreeMap();

MyItem Eight = new MyItem("Eight");

c.put(5, new MyItem("Five")); c.put(1, new MyItem("One")); c.put(8, Eight); c.put(3, new MyItem("Three"));

c.put(4, new MyItem("Four")); c.put(1, new MyItem("1")); c.put(8, Eight); c.put(9, new MyItem("Nine"));

c.remove(3); c.put(7, new MyItem("Seven"));

System.out.println(c);//output?

}

}

class MyLinkedHashMap{

public static void main(String[] args){

LinkedHashMap c = new LinkedHashMap();

MyItem Eight = new MyItem("Eight");

c.put(5, new MyItem("Five")); c.put(1, new MyItem("One")); c.put(8, Eight); c.put(3, new MyItem("Three"));

c.put(4, new MyItem("Four")); c.put(1, new MyItem("1")); c.put(8, Eight); c.put(9, new MyItem("Nine"));

c.remove(3); c.put(7, new MyItem("Seven"));

System.out.println(c);//output?

}

}

class MyHashSet{

public static void main(String[] args){

HashSet c = new HashSet();

MyItem Eight = new MyItem("Eight");

c.add(new MyItem("Five")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Three"));

c.add(new MyItem("Four")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Nine"));

c.remove(3); c.add(new MyItem("Seven"));

System.out.println(c);//output?

}

}

class MyTreeSet{

public static void main(String[] args){

TreeSet c = new TreeSet();

MyItem Eight = new MyItem("Eight");

c.add(new MyItem("Five")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Three"));

c.add(new MyItem("Four")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Nine"));

c.remove(Eight); c.add(new MyItem("Seven"));

System.out.println(c);//output?

}

}

class MyLinkedHashSet{

public static void main(String[] args){

LinkedHashSet c = new LinkedHashSet();

MyItem Eight = new MyItem("Eight");

c.add(new MyItem("Five")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Three"));

c.add(new MyItem("Four")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Nine"));

c.remove(3); c.add(new MyItem("Seven"));

System.out.println(c);//output?

}

}

class MyArrayList{

public static void main(String[] args){

ArrayList c = new ArrayList();

MyItem Eight = new MyItem("Eight");

c.add(new MyItem("Five")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Three"));

c.add(new MyItem("Four")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Nine"));

c.remove(3); c.add(new MyItem("Seven"));

System.out.println(c);//output?

}

}

class MyVector{

public static void main(String[] args){

Vector c = new Vector();

MyItem Eight = new MyItem("Eight");

c.add(new MyItem("Five")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Three"));

c.add(new MyItem("Four")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Nine"));

c.remove(3); c.add(new MyItem("Seven"));

System.out.println(c);//output?

}

}

class MyLinkedList{

public static void main(String[] args){

LinkedList c = new LinkedList();

MyItem Eight = new MyItem("Eight");

c.add(new MyItem("Five")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Three"));

c.add(new MyItem("Four")); c.add(new MyItem("One")); c.add(Eight); c.add(new MyItem("Nine"));

c.remove(3); c.add(new MyItem("Seven"));

System.out.println(c);//output?

}

}

class MyPriorityQueue{

public static void main(String[] args){

PriorityQueue c = new PriorityQueue();

MyItem Eight = new MyItem("Eight");

c.offer(new MyItem("Five")); c.offer(new MyItem("One")); c.offer(Eight); c.offer(new MyItem("Three"));

c.offer(new MyItem("Four")); c.offer(new MyItem("One")); c.offer(Eight); c.offer(new MyItem("Nine"));

System.out.println(c.peek());

System.out.println(c.poll());

c.offer(new MyItem("Seven"));

System.out.println(c);//output?

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值