public class AssertTest2 { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
float f1=Float.NaN;
float f2=f1;
float f3=1.2f;
try{
assert (f2==f1):f2=2;
f3=1.5f;
}catch(AssertionError ae){
f3++;
}
f3+=f2;
System.out.println("f3="+f3);
}}
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
float f1=Float.NaN;
float f2=f1;
float f3=1.2f;
try{
assert (f2==f1):f2=2;
f3=1.5f;
}catch(AssertionError ae){
f3++;
}
f3+=f2;
System.out.println("f3="+f3);
}}
且抛出异常,继续执行f3++f2=2; -> f2=2
f3++ -> f3=2.2f3+=f2 ->4.2
f3=4.2C:\>