+ 1
Can we use an if statement inside an if statement ?
15 Answers
+ 2
if (...) {
if (...) {
}
}
+ 2
Yes you can use .
+ 2
nested if and else if, else if can be more helpful sometimes...
if() {}
else if(){}
else{}
+ 2
yes
+ 1
Yes you can. For example.
int x = 2;
if(x>2?false:true){
System.out.println("x <= 2");
}
+ 1
Yes
+ 1
Yes
+ 1
yes,
example :
if(....){
............
if(....){
.............
}
}
+ 1
You Can try like that
import java.util.Scanner;
public class Programm {
Scanner input=new Scanner(System.in);
String name;
System.out.println("Please enter your first name");
name=input.nextLine ();
if (name.equals ("Varun")){
System.out.println(Hello Varun");
}
else if (name.equals ("Pandey")){
System.out.println ("You have used your lastname")}
else {
System.out.println ("Nice to meet you")}
}
}
have fun
0
Yes
0
nested
0
yes u can it is called nested ifs
0
u may use if n if
0
Yes it is nested if
- 7
Yes
if (int=0 if( ...))