ie:
If you live in the USA, then you live in North America.
if(country.equalsIgnoreCase("USA")) {
continent = "North America";
}I'll break this down.
Quote
If you live in the USA,
This is equivelent to:
if(country.equalsIgnoreCase("USA")) {That part is where all the requirements are set for the following to happen. Believe it or not, Java speaks English.
if(requirement) {
//what happens if requirement is met
}This is where the real action happens. This is what happens if the requirements are met.
Quote
then you live in North America.
This is equivelent to:
continent = "North America";
This will only be done if the country is USA.
Let's try this.
You live in Brazil.
country = "Brazil";
if(country.equalsIgnoreCase("USA") {Oh, but wait, your in Brazil. This won't work. The following will not be done.
if-then-else statements are about the same. They are basically two if-then statements combined.
There are two ways to use them.
if(req = true){
then();
} else {
ifReqWasntMet();
}or
if(req = true){
then();
} else if(req = false) {
ifReqWasntMet();
}If you read the beginning, you should understand this.
Understand? If not, then google biconditionals.
Anyway, this would be applied in nearly EVERYTHING that has requirements unless you use a switch.
Sign In
Register
Help

Bookmark
Del.icio.us
Digg
Email
Facebook
Google
Mixx
Reddit
StumbleUpon



Back to top
MultiQuote

