我是Java的新手,我有一个代码,里面有一个包。我的问题是我正在尝试在Jgrasp上运行代码,这是我的学校程序来运行代码。 Jgrasp不使用包。由于包裹,我无法运行它。我不知道包是如何工作的,但我为此编写了一个完整的代码并将其交给了一位朋友,他编辑了我的代码并将其编成一个包并说它有效。我不想要这个包,我想用他编写的完全编写的代码,而不是下面的主要方法。
package insta2;
import java.io.*;
import java.util.*;
class BottomUpApp {
public static void main(String[] args) throws IOException {
BottomUp bup;
Tree theTree = null;
int value;
String str;
while (true) {
System.out.print(" Enter first letter of balanced");
System.out.print(" unbalanced , show , or traverse : ");
int choice = getChar();
switch (choice) {
case 'b':
System.out.print(" Enter string : ");
str = getString();
bup = new BottomUp(str);
bup.balanced();
theTree = bup.getTree();
break;
case 'u':
System.out.print("Enter string: ");
str = getString();
bup = new BottomUp(str);
bup.unbalanced();
theTree = bup.getTree();
break;
case 's':
theTree.displayTree();
break;
case 't':
System.out.print(" Enter type 1, 2 or 3 : ");
value = getInt();
theTree.traverse(value);
break;
default:
System.out.print(" Invalid entry \n ");
}
}
}
public static String getString() throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
return s;
}
public static char getChar() throws IOException {
String s = getString();
return s.charAt(0);
}
public static int getInt() throws IOException {
String s = getString();
return Integer.parseInt(s);
}
}
答案 0 :(得分:0)
jGRASP对包没有任何问题。
我猜你的代码不在名为“insta2”的目录中。