package IO;
import java.io.*;
import java.util.ArrayList;
public class driver {
public static void main(String args[]) {
int s;
try {
//Scanner in = new Scanner(System.in);
//System.out.println("Enter The number of files you want to create");
//s = in.nextLine();
//takes the number of files
ArrayList<String> obj = new ArrayList<String>();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the number of files you want to create");
String num = br.readLine();
int x = Integer.parseInt(num);
// takes the names of file
for (int i = 0; i < x; i++) {
System.out.println("Enter the name for file:");
String name = br.readLine();
Integer.parseInt(name);
obj.add(name);
}
} catch (IOException o) {
System.out.println("Exception^^^^^^^^^^^^^");
}
}
}
上面是我的代码,但是当我在命令行上编译它,如javac driver.java然后java驱动程序,它给我错误,无法加载主类主...请帮我排序这个错误..这代码btw包含稍后要实现的文件处理!
答案 0 :(得分:1)
我修改了您的代码,请检查以下适用于我的代码..
import java.io.*;
import java.util.ArrayList;
public class Driver{
public static void main(String args[]){
int s;
try{
ArrayList<String> obj = new ArrayList<String>();
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the number of files you want to create");
String num = br.readLine();
int x=Integer.parseInt(num);
// takes the names of file
for(int i=0;i<x;i++){
System.out.println("Enter the name for file:");
String name = br.readLine();
Integer.parseInt(name);
obj.add(name);
}
}catch(Exception e){
}
}
}
答案 1 :(得分:0)