英文:
Is there a specific way to make a maze layout in Java?
问题
以下是翻译好的内容:
我尝试在Java中制作一个迷宫布局,但一直遇到错误。我已经修复了一些简单的错误,但是我无法消除其他错误。每次我改变代码,甚至菜单都不会显示出来。以下是我遇到的一些错误。
Main.java:53: 错误: 预期 '}'
"3[40mblack3[49m";
^
Main.java:54: 错误: 不是语句
"3[41mred3[49m"};
^
Main.java:54: 错误: 预期 ';'
"3[41mred3[49m"};
^
Main.java:59: 错误: 预期 <标识符>
custom.initializeOptions();
^
Main.java:60: 错误: 预期 <标识符>
System.out.println("Enter integer choice for width: ")
^
Main.java:60: 错误: 非法的类型开始
System.out.println("Enter integer choice for width: ")
^
Main.java:62: 错误: 预期 <标识符>
mapheight = custom.intInput(20,100);
^
MazeLayout.java:6: 错误: 无效的方法声明; 需要返回类型
public Mazelayout()
^
MazeLayout.java:63: 错误: 预期 <标识符>
System.out.print("3[0m");
^
MazeLayout.java:63: 错误: 非法的类型开始
System.out.print("3[0m");
^
MazeLayout.java:65: 错误: 预期 类、接口或枚举
}
英文:
I have tried making a maze layout in java but I keep getting errors. I have fixed the simple errors but I cannot get the other errors to go away. Every time I change the code like, even the menu won't show up.
Here are some of the errors I have.
Main.java:53: error: '}' expected
"3[40mblack3[49m";
^
Main.java:54: error: not a statement
"3[41mred3[49m"};
^
Main.java:54: error: ';' expected
"3[41mred3[49m"};
^
Main.java:59: error: <identifier> expected
custom.initializeOptions();
^
Main.java:60: error: <identifier> expected
System.out.println("Enter integer choice for width: ")
^
Main.java:60: error: illegal start of type
System.out.println("Enter integer choice for width: ")
^
Main.java:62: error: <identifier> expected
mapheight = custom.intInput(20,100);
^
MazeLayout.java:6: error: invalid method declaration; return type required
public Mazelayout()
^
MazeLayout.java:63: error: <identifier> expected
System.out.print("3[0m");
^
MazeLayout.java:63: error: illegal start of type
System.out.print("3[0m");
^
MazeLayout.java:65: error: class, interface, or enum expected
}
答案1
得分: 1
你需要为一个方法提供一个返回类型(第一个错误),否则它会被视为构造函数。
其余部分可能是稍后的语法错误,编译器无法确定如何恢复正常。
换句话说,你的源代码有问题。请考虑重新学习类定义。
英文:
You need to provide a return type for a method (the first error) or it is considered a constructor.
The rest is probably a syntax error a bit later from which the compiler cannot figure out how to get back on track.
In Other words - your source is broken. Consider studying class definitions again.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论