Professional Documents
Culture Documents
statements;
}
if (condition) {
statements;
} else {
statements;
}
if (condition) {
statements;
} else if (condition) {
statements;
} else {
statements;
}
==========================
class IfElseDemo {
public static void main(String[] args) {
=================================
//
import java.util.Scanner;
class Test
{
public static void main(String[] args) throws Exception
{
Scanner in = new Scanner(System.in);
String firstName, lastName;
int organDonorAnswer;
char sex;
String gender;
============================
import java.util.Scanner;
class Test
{
public static void main(String[] args) throws Exception
{
Scanner in = new Scanner(System.in);
boolean b;
b = true;
System.out.println(b);
b = false;
System.out.println(b);
b = in.nextBoolean();
System.out.println(b);
if (b) {
System.out.println(b);
}
if (b == true) {
System.out.println(b);
}
}
}
=============================