New to Java here.....
I am writing a program which I would like the user to enter an integer. The integer will then be used for some other calculations. My code so far is:
//read in input, cast to char.
n = (char)System.in.read();
//assign 'n' to new String.
s = new String[n];
//using parseInt, change to an integer.
num = Integer.parseInt(s);
However when I run this, I get the error...incompatible type for = can't convert java.lang.String[] to java.lang.String.
Not really sure how to correct the problem.
Thanks for any help.
Mark
I am writing a program which I would like the user to enter an integer. The integer will then be used for some other calculations. My code so far is:
//read in input, cast to char.
n = (char)System.in.read();
//assign 'n' to new String.
s = new String[n];
//using parseInt, change to an integer.
num = Integer.parseInt(s);
However when I run this, I get the error...incompatible type for = can't convert java.lang.String[] to java.lang.String.
Not really sure how to correct the problem.
Thanks for any help.
Mark