0

Why the output is hi when x=7,if(x<42)

I know how I can use it but don't know how it's getting executed

24th Sep 2017, 3:17 PM
Shikhar
Shikhar - avatar
6 Answers
+ 3
There is no output given in that code.
24th Sep 2017, 3:19 PM
Rrestoring faith
Rrestoring faith - avatar
+ 2
if (7 is less then 42){ do somthing();}
24th Sep 2017, 3:25 PM
D_Stark
D_Stark - avatar
+ 1
@shikhar your missing a semicolon in your code at the end of the print method();} also use // for single line comments also int x = 7; your initalizing x to a value here so x uses 7.
24th Sep 2017, 4:25 PM
D_Stark
D_Stark - avatar
0
output is getting as Hi Not understand in it's reason
24th Sep 2017, 3:21 PM
Shikhar
Shikhar - avatar
0
why we are taking x as 7
24th Sep 2017, 3:22 PM
Shikhar
Shikhar - avatar
0
public class{ public static void main(String[ ] args) { int x =7; if(x < 42);{ System.out.println("Hi") } } } / result is Hi/
24th Sep 2017, 3:32 PM
Shikhar
Shikhar - avatar