0
Can anyone tell me whats wrong in this...
https://code.sololearn.com/c5M0uKD2IFUo/?ref=app https://code.sololearn.com/c5M0uKD2IFUo/?ref=app
6 Réponses
+ 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");
}
}
}
+ 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");
+ 2
I started my coding recently can anyone help me pls.
+ 1
NonStop CODING thank you brother...
+ 1
ganesh annangi
Your Welcome!👍
0
I added the double codes also... But it showing some error..