JB1000
JB1000

Reputation: 1

Taking char and int inputs

I am currently working on a Knight's tour implementation in Java. I am trying to take the user input in the form (file)(rank) on my board.

File would be a char (a, b, c or d) and rank an int (1, 2 or 3).

I know how to get the input of these individually but how would I combine the input of the two, so that for example 'd2' is valid.

I am a beginner to java so any help would be much appreciated.

Upvotes: 0

Views: 94

Answers (2)

JihadiOS
JihadiOS

Reputation: 431

you can use String format like this:

String input = String.format("%s"+"%d", file, rank);

where file is your char input and rank is your int input

Upvotes: 0

dryairship
dryairship

Reputation: 6077

You can do this:

String st = ch+""+in;

Upvotes: 1

Related Questions