当前位置: 技术问答>java相关
菜鸟学JAVA送分
来源: 互联网 发布时间:2015-06-27
本文导语: Question 1 File tony = new File("hhh.txt"); if (tony.createNewFile()){ System.out.print("ok!"); } javac Delete.java 出现 :error message Delete.java:28: Method createNewFile() not found in class java.io.File. 我记得file下有createNewFile()撒? /**********...
Question 1
File tony = new File("hhh.txt");
if (tony.createNewFile()){
System.out.print("ok!");
}
javac Delete.java 出现 :error message
Delete.java:28: Method createNewFile() not found in class java.io.File.
我记得file下有createNewFile()撒?
/*****************/
Question 2
File ff = new File("F:JAVAEXPcomjackexamplesIOjj123.txt");
编译时出现
Delete.java:10: Invalid escape character.
Why??
/********************/
Question 3
try{......}
catch(IllegalArgumentException e){
System.err.Println(e.getMessage());
}
编译时出现
Delete.java:17: Method Println(java.lang.String) not found in class java.io.PrintStream.
System.err.Println(e.getMessage());
^
这怎么出错了?
File tony = new File("hhh.txt");
if (tony.createNewFile()){
System.out.print("ok!");
}
javac Delete.java 出现 :error message
Delete.java:28: Method createNewFile() not found in class java.io.File.
我记得file下有createNewFile()撒?
/*****************/
Question 2
File ff = new File("F:JAVAEXPcomjackexamplesIOjj123.txt");
编译时出现
Delete.java:10: Invalid escape character.
Why??
/********************/
Question 3
try{......}
catch(IllegalArgumentException e){
System.err.Println(e.getMessage());
}
编译时出现
Delete.java:17: Method Println(java.lang.String) not found in class java.io.PrintStream.
System.err.Println(e.getMessage());
^
这怎么出错了?
|
Question 1
程序没问题
Question 2
把""改为"/"
Question 3
System.err.Println==>System.err.println
晕倒。。。。
程序没问题
Question 2
把""改为"/"
Question 3
System.err.Println==>System.err.println
晕倒。。。。
|
question 1:
import java.io.File;
import java.io.IOException;
class F {
public F() throws IOException {
File tony = new File("abc.txt");
if (tony.createNewFile()){
System.out.print("ok!");
}
}
}
public class Test2 {
public static void main(String[] args) throws IOException{
new F();
}
}
编译通过,运行也没问题。
import java.io.File;
import java.io.IOException;
class F {
public F() throws IOException {
File tony = new File("abc.txt");
if (tony.createNewFile()){
System.out.print("ok!");
}
}
}
public class Test2 {
public static void main(String[] args) throws IOException{
new F();
}
}
编译通过,运行也没问题。