0
i dont know why but can anyone explain why output is "no output"
public class Program { public static void main(String[] args) { int x = 7; if(x < 42) { System.out.println("Hi"); elseif {System.out.println("yo");} } } }
8 Answers
+ 4
public class Program {
public static void main(String[] args) {
int x = 7;
if(x < 42)
System.out.println("Hi");
else System.out.println("yo");
}
}
+ 1
the else if statement is included in the if braces...so it will show only hi...better to use braces even if there is single statement âșïž
0
I think it is compile error rather than no output.
0
there is a structure error.
0
you have not given space between else if . it should be else if or you can write simply else
0
Incorrect placement of curly braces. The braces that you started after if contains an else if clause without if clause that's why there is no output. Rest everything is correct
0
which one i use for else statement..else or else if.which one is correct.any one can explain here please:-(
0
/* You have to be careful while writing the coding as little mistake on your codes will leads to many error. First of all if you want to learn Java properly use Command Prompt to run your programmes and write your code on text editor(like Notepad++, Sublime Text etc) it . And about your error here, there are many syntex error.
So the corrected code will be : */
public class Program {
public static void main(String[] args) {
int x = 7;
if(x < 42) {
System.out.println("Hi");
}
else {
System.out.println("yo");
}
}
}
//keep coding