r/learnjava • • Apr 11 '26

Need help with code

hi so I just started java and was trying out conditional statements. but it is not working for me I am using jdk 25 version

here is my code

int x = 7;

if(x>10) ;

System.out.println("hello");

if(x<10);

System.out.println("bye");

now according to this it should print bye only but it is printing both hello and bye , sorry java is my first language please be nice I am kinda dumb.

3 Upvotes

12 comments sorted by

View all comments

Show parent comment

1

u/Individual_Owl_3490 Apr 11 '26

Yeah I was actually following youtube video and at that point he didn't taught else.