Search This Blog

save java programs with".java" extension

examples :

helloworld.java
sample.java
match.java
send-mail.java

quick links

nested if in java

/* grade */

class place
{
public static void main(String args[])
{
String country="india" , state="ap", city="nellore";

if(country=="india")
{
System.out.print("you are in india");
if(state=="ap")
{
System.out.print(", ap state ");
if(city=="nellore")
{
System.out.println("at nellore city");
}
else
{
System.out.println("not in nellore ");
}
}
else
{
System.out.println("not in ap");
if(state=="up")
{
System.out.println("you are in up state");
}
}
}
else
{
System.out.println("you are not in india");
}
}
}

output :

you are in india , ap state at nellore city