import java.io.File;public class Test3{
public static void main(String[] args){
File c = new File("test.txt");
if(c.exists()){
System.out.println("存在");
c.delete();
if(c.exists())
{
c = new File("C:/Users/zhanyayun/Desktop/java/test.txt");
System.out.println("budjlsj");
}
}
else
System.out.println("hello");
}}
为什么这个程序不输出 “存在”
public static void main(String[] args){
File c = new File("test.txt");
if(c.exists()){
System.out.println("存在");
c.delete();
if(c.exists())
{
c = new File("C:/Users/zhanyayun/Desktop/java/test.txt");
System.out.println("budjlsj");
}
}
else
System.out.println("hello");
}}
为什么这个程序不输出 “存在”
所以就打印存在了呗
看哪个语句块执行就知道有没有存在了!
{
c = new File("C:/Users/zhanyayun/Desktop/java/test.txt");
System.out.println("budjlsj");
}存在都放“存在”的后面了。怎么存在?