java - I have trouble with static main method and inputting non-static values -


this question has answer here:

i working on school project, building chess-game. have board creates arrays , fill board pieces.

now, want instantiate new board in game class , use console input player moves. make simple possible, trouble inputting non-static variables.

for instance:

public class test extends consoleprogram{  public static double a1;   public static void main(string[] args) {     a1 = readline("insert value of a1");      system.out.println(a1);  } }  

more info on readline() here

as see, won't work java complaining cannot make static reference non-static method readline()

how work around this? maybe there basic don't understand..

as always, thank quick , insightful answers!

if don't want make readline method static, call on instance:

public static void main(string[] args) {      test me = new test();      a1 = me.readline("insert value of a1");      system.out.println(a1);   } 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -