+ 1

Can we use an if statement inside an if statement ?

17th Jul 2016, 5:48 PM
VARUN PANDEY
VARUN PANDEY - avatar
15 Antworten
+ 2
if (...) { if (...) { } }
17th Jul 2016, 7:14 PM
FreakManMega
+ 2
Yes you can use .
17th Jul 2016, 7:26 PM
kevinpp24
kevinpp24 - avatar
+ 2
nested if and else if, else if can be more helpful sometimes... if() {} else if(){} else{}
18th Jul 2016, 9:29 AM
Petar Suvajac
Petar Suvajac - avatar
+ 2
yes
7th Jun 2017, 6:33 AM
Ashutosh Kumar
Ashutosh Kumar - avatar
+ 1
Yes you can. For example. int x = 2; if(x>2?false:true){ System.out.println("x <= 2"); }
18th Jul 2016, 1:41 PM
WPimpong
WPimpong - avatar
+ 1
Yes
20th Jul 2016, 6:50 PM
iJames
iJames - avatar
+ 1
Yes
26th Jul 2016, 6:08 PM
bedrovitch
bedrovitch - avatar
+ 1
yes, example : if(....){ ............ if(....){ ............. } }
5th Oct 2016, 12:16 PM
Ravindra
Ravindra - avatar
+ 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
1st Dec 2016, 8:15 PM
Mohamed Haque
Mohamed Haque - avatar
0
Yes
17th Jul 2016, 6:03 PM
Luis Contreras Guerra
Luis Contreras Guerra - avatar
0
nested
17th Jul 2016, 8:09 PM
oz10h
oz10h - avatar
0
yes u can it is called nested ifs
10th Nov 2016, 5:50 PM
Senpai Anubhav
Senpai Anubhav - avatar
0
u may use if n if
21st Nov 2016, 2:11 PM
chandra t
chandra t - avatar
0
Yes it is nested if
17th Dec 2016, 1:57 PM
Eliecer Cedano
Eliecer Cedano - avatar
- 7
Yes if (int=0 if( ...))
19th Jul 2016, 4:54 AM
Von Aceber Garcia
Von Aceber Garcia - avatar