Java面试2012-06-04
1、java中不用第三方变量交换两个int变量的值
a = a + b;b = a - b;a = a - b;
a = a * b;b = a / b;a = a / b;
a = a ^ b;b = a ^ b;a = a ^ b;
// 递归列出创建时间最早的文件private void funList(File file) {//log(file);if (file.isDirectory()) {File[] files = file.listFiles();if (files == null) {return;} else {for (File f : files) {funList(f);}}} else {if (!file.isHidden()) {//deleteArea.setText("");//deleteArea.setText(file.toString());log(file);fileDateLists.add(file);} else {// log("隐藏文件:"+file);}}}//delete dirvoid deleteDir(File file) {if (file.isDirectory()) {File[] files = file.listFiles();for (int i = 0; i < files.length; i++) {File f = files[i];if (f.isDirectory()) {deleteDir(files[i]);} else {if (!f.delete()) {System.err.println(f.getAbsolutePath() + "cann't be deleted .");}}}}if (!file.delete()) {System.err.println(file.getAbsolutePath() + "cann't be deleted .");}}
Class Demo {synchronized A () {....}synchronized B () {....}}