Hi, I'm having problem with this code.
import java.io.*; public class ConditionalStatement { public static void main(String[]args) { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String num; try { num = input.readLine(); int num1 = Integer.parseInt(num); int x=(num1>=0)? "positive":"negative"; System.out.println("The number entered is "+x+"."); } catch (IOException e) { System.out.println("Error!"); } } }
How come this line says "incompatible types"?
int x=(num1>=0)? "positive":"negative";
I just declared x as integer. What's wrong with that?