The if Statement
if (x < y)
{y = 0;x = x + 1;
}
else
{x = y;
}
if (x < y)
{y = 0;x = x + 1;
}
The if-return Statement
if (x < y)
{return;
}
print (x);
return;
注意:2到3 没有边
while and for Loops
x = 0;
while (x < y)
{y = f (x, y);x = x + 1;
}
for (x = 0; x < y; x++)
{y = f (x, y);
}
do Loop, break and continue
x = 0;
do
{y = f (x, y);x = x + 1;
} while (x < y);
println (y)
x = 0;
while (x < y)
{y = f (x, y);if (y == 0){break;} else if (y < 0){y = y*2;continue;}x = x + 1;
}
print (y);
The Case (switch) Structure
read ( c) ;
switch ( c )
{case ‘N’:y = 25;break;case ‘Y’:y = 50;break;default:y = 0;break;
}
print (y);
read ( c) ;
switch ( c )
{case ‘N’:y = 25;break;case ‘Y’:y = 50;default:y = 0;break;
}
print (y);
The Exception (try-catch) Structure
try
{s = br.readLine();if (s.length() > 96)throw new Exception(“too long”);
} catch IOException e) {e.printStackTrace();
} catch Exception e) {e.printStackTrace();
}
return (s);