gpt4 book ai didi

java - 无法对非静态字段方法第 17 行和第 9 行进行静态引用

转载 作者:行者123 更新时间:2023-12-02 09:31:02 26 4
gpt4 key购买 nike

我正在尝试保存来自扫描仪的输入,但我始终无法进行静态引用

  import java.util.Scanner;
public class Month {
//instance fields
int number;
//constructor methods
private String names;
public Month(String names){
names = ("January February March April May June July August September October November December");
}
//main method
public static void main(String[]args){
System.out.println("Enter number from 1 - 12: ");
Scanner one = new Scanner (System.in);
number=one.nextdouble();
}
}

最佳答案

数字标记为静态

静态整数;

关于java - 无法对非静态字段方法第 17 行和第 9 行进行静态引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57978731/

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