0

Can anyone help me here?

public class Program { public static void main(String[] args) { int a=1; if(a>3); { System.out.println(a); }}} Here the output is 1 ,even though a>3.This is because if terminator in if statement.Please explain

7th Jul 2020, 10:17 AM
Ajoh Pv
Ajoh Pv - avatar
2 Answers
0
You have put semi colon to (;) to if statement remove that semicolon. if(a>3) ;
7th Jul 2020, 10:22 AM
Shobhith J B
Shobhith J B - avatar
0
If you put semicolon to if statement, the compiler will not consider it as a if statement so the comparsion will not be performed Hope it helps
7th Jul 2020, 10:25 AM
Shobhith J B
Shobhith J B - avatar