我得到了

public static void main(String[] args) {

    System.out.println("Trying to open lock");
    System.out.println("Trying ");
    ComboLock numbers = new ComboLock();
    int number1 = numbers.ComboLock;
    `


我试图从此类中调用ComboLock

public class ComboLock {

private int number1, number2, number3;
private boolean locked;
public static final int SMALLEST_NUMBER = 1;
public static final int LARGEST_NUMBER = 39;

public ComboLock() {
    locked = true;
    Random rand = new Random();
    number1 = rand.nextInt(LARGEST_NUMBER - SMALLEST_NUMBER) + SMALLEST_NUMBER;
    number2 = rand.nextInt(LARGEST_NUMBER - SMALLEST_NUMBER) + SMALLEST_NUMBER;
    number3 = rand.nextInt(LARGEST_NUMBER - SMALLEST_NUMBER) + SMALLEST_NUMBER;
}


我在尝试制作number1.ComboLock();时出现错误说找不到符号

最佳答案

public ComboLock() {


是一个构造函数,您正在尝试将其作为函数/方法访问

int number1 = numbers.ComboLock;

09-25 21:45