How do I fix the error where I cannot make a static reference to a non-static input field?

后端 未结 5 711
刺人心
刺人心 2021-01-26 22:38

I am learning java. I wrote the following code but I am getting this error \"cant make a static reference to a non static input field\" in Arrayfunction(), when I try to take in

5条回答
  •  悲&欢浪女
    2021-01-26 23:04

    Scanner is not defined as static therefore is in the wrong scope

    Either create the Scanner instance inside Arrayfunction or create your scanner with

    private static Scanner input= new Scanner(System.in);
    

提交回复
热议问题