Beginner problem Query | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Beginner problem Query

I don't know what I am doing wrong. I am a beginner in JAVA. Please guide.

7th Sep 2021, 6:10 AM
Ojas Kanotra
Ojas Kanotra - avatar
2 Answers
+ 3
You need to remove the semicolon in second else if condition. else if(condition){ } Also, You're missing a `}` at the end.
7th Sep 2021, 7:06 AM
Simba
Simba - avatar
+ 1
public class Program { public static void main(String[] args) { int age = 40; if(age <= 17) { System.out.println("You are small bro");} else if(age >=35) { System.out.println("Time for heaven");} else if(age >= 18 && age <= 34); { System.out.println("Welcome bro");} else{ System.out.println("I can't help you bro"); } } Whats wrong here ?
7th Sep 2021, 6:56 AM
Ojas Kanotra
Ojas Kanotra - avatar