[讨论]关于assert关键字
public class TryAssertions{
public static void main(String args[])
{
int daysInMonth = 32;
if (daysInMonth ==30)
{
System.out.println("Month is April,June,September,or November");
}else if (daysInMonth ==31)
{
System.out.println("Month is January,March,May,July,August,October,or December.");
}else if(daysInMonth ==28||daysInMonth == 29)
{
System.out.println("Month is February.");
}else
{
assert false:"DaysInMonth has the value "+daysInMonth;
}
}
}
上面的程序在eclipse中就不能运行,可是在JDK中就可以!为什么呢!?
还有就是这个断言关键字assert在实际运用中有没有用呢!?
JAVA高手可以给解说一下不!?
[此贴子已经被作者于2006-5-3 1:28:44编辑过]