This code works fine for me.
int num1 = -1;
String x = (num1 >= 0 ? "positive" : "negative");
System.out.println(x);
// Json
Type: Posts; User: Json
This code works fine for me.
int num1 = -1;
String x = (num1 >= 0 ? "positive" : "negative");
System.out.println(x);
// Json
Rewrite it to be this.
String x=(num1 >= 0 ? "positive" : "negative");
I think your parenthesis was in the wrong place.
// Json
In the code you have.
int x=(num1>=0)? "positive":"negative";
You are trying to check the value of num1 and return a string and assign it to int x. Change the int x to be String x.
// Json