0
Why the ! Symbol cannot or is not used in the system.out.println("") when NOT operator is taking place at the if statement.
public class Program { public static void main(String[] args) { int age = 25; if(!(age > 18)) { System.out.println("Too Young"); } else { System.out.println("Welcome"); } } } I am asking the question that, whether we should not use ! Symbol inside println statement as "Welcome!"
5 Antworten
+ 1
if the '!' is inside the "" it's treated like a String and not like the not-operator ...
so yeah you can do that 😄
+ 1
they don't cover everything in the tutorial aspecially obvious things ...
a String can contain any character, a q, a ! and even a 🙂
+ 1
Sololearn itself is not clear about that..i think so..anyhow thanks!
0
I don't get your question
,but you can replace '!(age > 18)' with 'age <= 18'
0
But if u check in the java tutorial topic and in conditions and loops and inside that logical operators and find NOT operator, they've not used ! Symbol inside the println statement. Why is it so