gpt4 book ai didi

java - JOGL 中的 Hello World

转载 作者:行者123 更新时间:2023-12-01 15:33:35 27 4
gpt4 key购买 nike

我是 JavaJogl 的新手,最近遇到了以下错误:

第一行代码错误:

"The import net cannot be resolved" 

第二行:

Multiple markers at this line
- Syntax error, insert "}" to complete ClassBody
- Syntax error, insert "}" to complete ClassBody

换句话说,代码中的方括号和圆括号是不平衡的。

import net.java.games.jogl.*;
public class HelloWorld {
public static void main (String args[]) {
try {
System.loadLibrary("jogl");
System.out.println(
"Hello World! (The native libraries are installed.)"
);

现在代码已缩进,很明显我缺少几个 }。我已经吸取了教训,将从现在开始缩进我的代码。

最佳答案

类没有修改访问权限:public class HelloWorld 应为 class HelloWorld

您的大括号不匹配 - 您打开了一些大括号,但没有关闭它们。它应该看起来像这样:

public class HelloWorld
{ // open HelloWorld

public static void main (String args[])
{ // open main
try
{ // open try
System.loadLibrary("jogl");
System.out.println("Hello World! (The native libraries are installed.)");
} // close try
catch (Exception e) // all try's need a catch
{ } // even if the catch does nothing
} // close main

} // close HelloWorld

对于导入 Unresolved 情况,通过。其他人会比我更了解这个具体问题:)

关于java - JOGL 中的 Hello World,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9245744/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com