Using a variable to set an object array in java -
when set object array such as:
player[] player = new player[amountofplayers];
i use:
amountofplayers = br.read();
to variable amountofplayers
. whenever run program type in 3 when asked set amountofplayers
output says there 51 players.
though when set new player
array to: new player[3]
; works.
anyone know why be?
the problem read char
, interpret integer. character 3
has ascii code 51
.
it easier use scanner
bufferedreader
read input, suggested prasad.
Comments
Post a Comment