简体   繁体   中英

The method I am trying to call is not returning a value

I'm trying to assign the return of a method to an int, but it's giving me an error "cannot find symbol symbol : variable columnResult"

Here is the code:

public void start() {
    String inputString = "XOXOXOO     X     XXO         X     OXO   ";


    columnResult();
    int column = columnResult;

    enterToken("X", inputString,column);    

  }
  private int columnResult(){
    System.out.println("Enter column for X:");
    String keyInput = Keyboard.readInput();
    int column1 = Integer.parseInt(keyInput);
    return column1;
  }

How can I fix it?

Try

int column = columnResult();

instead of columnResult(); int column = columnResult;

You must assign the result of the function right to the integer.

you should directly write

int column = columnResult();

Since it is a method which returns an int

You should be doing

int column = columnResult();

not 

int column = columnResult;
columnResult();
int column = columnResult;

should be

int column = columnResult();

Change to -

int column = columnResult();

By just calling columnResult(); and not assigning the returned value you are loosing it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM