String Compare not working
Hi all, sorry for simplicity of this question but its bugging me and I'm just frustrated now. Java and how their strings work in IF statements confuses me a little. They don't behave like C++.
basically I have a function that looks like
my read_input function looks like
String option = read_input();
if(option.compareTo("y") == 1)
do thing 1
do thing 2
So, when I press "y" it does thing 2. I want thing 1 dang it! So, I must be doing something fundamentally incorrect here. Is my string compare wrong.
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader stdin = new BufferedReader(isr);
output = stdin.readLine();
I repeat the function a little later in the program to enter number of days.
and when I enter
String select_days = read_input();
int num_days = Integer.parseInt(select_days.toString());
It throws a number exception at me.
What am I doing wrong?