12th Mar 2022, 3:27 AM
ganesh annangi
7 Antworten
+ 3
Your if else syntx is not correct Open Curly bracket will be after if , else then closing curly bracket Solution: public class Program { public static void main(String[] args) { int x= 5; if (x<7) { System.out.println("hi"); } else { System.out.println("bye"); } } }
12th Mar 2022, 4:18 AM
Pratibha
Pratibha - avatar
+ 4
ganesh annangi Your Mistakes: Line 8, " if " does not ends with semicolon Line 7, 11, Improper placing of brackets, Braces are used for creating body of a function. inside println, always use single or double quotes to print a string. No need to use quotes when printing a variable. /*****************************************/ Correct way: public class Program { public static void main(String[] args) { int x= 5; if (x<7) { System.out.println("hi"); } else{ System.out.println("bye"); } } } /*****************************************/ Tip: when using one statement inside if and else you can write it without using brackets like this if (x<7) System.out.println("hi"); else System.out.println("bye");
12th Mar 2022, 4:09 AM
NonStop CODING
NonStop CODING - avatar
+ 2
I started my coding recently can anyone help me pls.
12th Mar 2022, 3:28 AM
ganesh annangi
+ 1
NonStop CODING thank you brother...
12th Mar 2022, 4:15 AM
ganesh annangi
+ 1
ganesh annangi Your Welcome!👍
12th Mar 2022, 4:15 AM
NonStop CODING
NonStop CODING - avatar
0
I added the double codes also... But it showing some error..
12th Mar 2022, 4:08 AM
ganesh annangi