public class prac01 {
public static void main(String[] args){
File file=new File("demo");
deletFile(file);
}
public static void deletFile(File file){
File[] arrFile=file.listFiles();
if(arrFile!=null){
for(File f:arrFile){
if(f.isDirectory()){
deletFile(f);
}else{
System.out.println(f.getName()+"--------------" +f.delete());}
}
System.out.println(file.getName()+"----------"+file.delete());
}
}
}

package practice;
import java.io.File;
public class Prac02 {
public static void main(String[] args){
File file=new File("E:\\JavaSE");
File[] fileArray=file.listFiles();
for(File f: fileArray ){
if(f.isFile()){
if(f.getName().endsWith(".java")){
System.out.println(f.getAbsolutePath());
}
}
}
}
}

3:下面程序段的执行结果是什么?( B )
public class Foo{
public static void main(String[] args){
try{
return;}
finally{System.out.println("Finally");
}
}
}
A.编译能通过,但运行时会出现一个例外。 B.程序正常运行,并输出 "Finally"。
C.程序正常运行,但不输出任何结果。 D.因为没有catch语句块,所以不能通过编
4:对于已经被定义过可能抛出异常的语句,在编程时( A )。
A.必须使用try/catch语句处理异常,或用throw将其抛出。
B.如果程序错误,必须使用 try/catch语句处理异常。
C.可以置之不理。
D.只能使用try/catch语句处理。
5:哪个关键字可以抛出异常?( B )
A.transient B.throw C.finally D.catch
6:请问所有的异常类皆继承哪一个类?( A)
A.java.lang.Throwable B.java.lang.Exception
C.java.lang.Error D.java.io.Exception
7.System类在哪个包中?( B )
A.java.awt B.java.lang C.java.util D.java.io
package practice;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;
public class Prac08 {
public static void main(String[] args) {
HashMap<Integer, String> pokerMap = new HashMap<Integer, String>();
String[] colors = { "♣", "♠", "♥", "◆" };
String[] nums = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"J", "Q", "K" };
ArrayList<Integer> indexs = new ArrayList<Integer>();
int index = 0;
for (String num : nums) {
for (String color : colors) {
pokerMap.put(index, num + color);
indexs.add(index);
index++;
}
}
indexs.add(index);
pokerMap.put(index, "大王");
index++;
indexs.add(index);
pokerMap.put(index, "小王");
Collections.shuffle(indexs);
Collections.shuffle(indexs);
Collections.shuffle(indexs);
TreeSet<Integer> zxc = new TreeSet<Integer>();
TreeSet<Integer> wzx = new TreeSet<Integer>();
TreeSet<Integer> sdd = new TreeSet<Integer>();
TreeSet<Integer> dp = new TreeSet<Integer>();
for (int i = 0; i < indexs.size(); i++) {
if (i >= pokerMap.size() - 3) {
dp.add(indexs.get(i));
}
if (i % 3 == 0) {
zxc.add(indexs.get(i));
} else if (i % 3 == 1) {
wzx.add(indexs.get(i));
} else if (i % 3 == 2) {
sdd.add(indexs.get(i));
}
}
lookPai("周星驰", zxc, pokerMap);
lookPai("吴宗宪", wzx, pokerMap);
lookPai("宋丹丹", sdd, pokerMap);
lookPai("底牌", dp, pokerMap);
}
private static void lookPai(String name, TreeSet<Integer> list,
HashMap<Integer, String> pokerMap) {
System.out.println(name);
for (Integer in : list) {
String pai = pokerMap.get(in);
System.out.print(pai + " ");
}
System.out.println();
}
}