[英]Error:Could not find or load main
It gives me that error when I launch, the class name is AQueueClass Any help?当我启动时它给了我这个错误,类名是 AQueueClass 有什么帮助吗?
package `com.thekyle.hi;`
class QDemo {
// a queue class for characters
char q[]; // this array holds the queue
int putloc, getloc; // the put and get indices
QDemo(int size) {
q = new char[size + 1];
putloc = getloc = 0;
}// put a character into the queue
void put(char ch) {
if (putloc == q.length - 1) {
System.out.println(" - Queue is full silly- ");
return;
}
putloc++;
q[putloc] = ch;
}
char get() {// gets a character from the queue
if (getloc == putloc) {
System.out.println(" Queue is empty");
return (char) 0;
}
getloc++;
return q[getloc];
}
}
class AQueueClass {
public static void main(String args[]) {
QDemo bigQ = new QDemo(100);
QDemo smallQ = new QDemo(4);
char ch;
int i;
System.out.println("Using bigQ to store the alphabet");
for (i = 0; i < 26; i++) {
bigQ.put((char) ('A' + i));
// retrieve and display elements from bigQ
System.out.println("Contents of bigQ: ");
for (i = 0; i < 26; i++) {
ch = bigQ.get();
if (ch != (char) 0)
System.out.print(ch);
}
System.out.println("\n");
System.out.println("Using small q to generate errors");
for (i = 0; i < 5; i++) {
System.out.print("Attemting to store " + (char) ('Z' - i));
smallQ.put((char)('Z' - i));
System.out.println();
}
System.out.println();
System.out.println("Contents of smallQ: ");
for (i = 0; i < 5; i++) {
ch = smallQ.get();
if( ch != (char) 0 ) System.out.print(ch);
}
}
}
}
If its a class path problem, where do I find the class path?如果是类路径问题,我在哪里可以找到类路径? And since it says that I need more detail, so here is some filler.因为它说我需要更多细节,所以这里有一些填充物。
By what name you have save your java file.你用什么名字保存你的java文件。 If you have two class in your java file then try to made you class containing main() method as a public class.如果您的 java 文件中有两个类,请尝试将包含main()方法的类作为公共类。
Try to save your file by the name AQueueClass and also add public keyword in front of AQueueClass class.尝试以名称AQueueClass保存您的文件,并在AQueueClass类前面添加public关键字。 Compile it and again run it.编译它并再次运行它。 I think it will work .我认为它会起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.