I want to print a sentence like:
boolean someSetting = true;
System.out.println("Running experiment " + (someSetting)? "on" : "off");
Obviously this won't compile. Is there any other suggestion to do this?
add brackets around it to evaluate that expression to String value
System.out.println("Running experiment " + ((someSetting)? "on" : "off"));
without brackets it tries to contact (+) String and boolean and puts it as a conditional expression which is invalid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With