疯狂javaj讲义第八章练习

第一题:

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Homework1 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        HashSet arrSet=new HashSet();
        Scanner s=new Scanner(System.in);
        //while(s.hasNext())
        for(int i=0;i<5;i++)
        {
            arrSet.add(s.next());
        }
        System.out.println(arrSet);

    }

}

第二题:


import java.awt.List;
import java.util.ArrayList;

public class Homework2 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String[] books={"111","222","333","444","555"
                ,"666","888","999","101010"};
        ArrayList bookList=new ArrayList();
        for(int i=0;i

第三题


import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;

public class Homework3 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String[] str={"a","b","a","b","c","a","b","c","b"};
        HashMap hm=new HashMap();
        for(int i=0;i

你可能感兴趣的:(疯狂javaj讲义第八章练习)