gpt4 book ai didi

java - 编译代码时出现错误: Could not find or load main class .

转载 作者:行者123 更新时间:2023-12-02 05:55:41 25 4
gpt4 key购买 nike

当我编译以下代码时,它会出现一条错误消息:

Error: Could not find or load main class javaapplication6.JavaApplication6
Java Result: 1.

我使用的软件是Netbeans IDE8.0

import  java.util* ;
package javaapplication6 ;

public class JavaApplication6 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in = new Scanner(System.in) ;
System.out.println ("Please enter your user name!");

String userName = in.nextline ();
System.out.println("please enter the passcode" + userName + ".");

int passcodeFromUser = in.next.Int ();
int passcode = 7001 ;

if (passcodeFromUser == passcode)
{
System.out.println("welcome" + username + "!" );
}
else
{
System.out.println("Acess Denied");
}
}

}

最佳答案

您必须将包语句声明为类的第一个语句,如下所示

package javaapplication6 ;
import java.util.*;

关于java - 编译代码时出现错误: Could not find or load main class .,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23109273/

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