shewontreply
shewontreply

Reputation: 51

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?

Upvotes: 1

Views: 116

Answers (5)

devang
devang

Reputation: 5516

Change to -

int column = columnResult();

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

Upvotes: 0

Valerio Marcellino
Valerio Marcellino

Reputation: 308

you should directly write

int column = columnResult();

Since it is a method which returns an int

Upvotes: 2

Gábor Bakos
Gábor Bakos

Reputation: 9100

columnResult();
int column = columnResult;

should be

int column = columnResult();

Upvotes: 0

Steffen Blass
Steffen Blass

Reputation: 276

Try

int column = columnResult();

instead of columnResult(); int column = columnResult;

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

Upvotes: 2

Uchenna Nwanyanwu
Uchenna Nwanyanwu

Reputation: 3204

You should be doing

int column = columnResult();

not 

int column = columnResult;

Upvotes: 0

Related Questions