use assert in 1.4 wrap up the System.out as another class like Debug. such as: class Debug{ public final debug(String msg){System.out.println(msg);} } when publishing, comment out the System.out.println in the debug() method. Theoretically, static final variable does not have to use memory. Even though Java does, Java does not care that little memory overhead at all.
not possible. although there're differences between different version, you are only targeting one version when you write code.even standard C does not have this problem.conditional compilation makes it harder to maintain your code.
那当初为什么要在C中引入宏,现在的assert不也是宏来的吗?
It's just a trade-off. macro makes something easier, but also makes many things hard. it just depends on the language designer's decision. at the beginning, Java decided to keep it simple. and now, assert is introduced, which is one step toward C's side. but assert is still not as flexible as macro, so not so dangerous as macro as well.
Java prefers simplicity and robustness to flexibility. Do you know refactoring? Now, many refactoring theory is only based on smalltalk and Java. C/C++ is too hard to be refactored in generalbut, actually I don't quite like Java's over-zealous insistence on language's simplicity too much. Many things like enum, const annotation(most importantly) should be there. My english? don't joke on me. you don't see how awkward I am when I speak to those GuiZi.
没有宏,那如果在编程时插入测试语句,发布时就要一句一句删去那些测试语句了呀~
还有一些常量的定义怎么办?(用static好像耗内存呀)
wrap up the System.out as another class like Debug.
such as:
class Debug{
public final debug(String msg){System.out.println(msg);}
}
when publishing, comment out the System.out.println in the debug() method.
Theoretically, static final variable does not have to use memory.
Even though Java does, Java does not care that little memory overhead at all.
at the beginning, Java decided to keep it simple. and now, assert is introduced, which is one step toward C's side. but assert is still not as flexible as macro, so not so dangerous as macro as well.
ajoo(聪明的一猪):
你是留学生吗?这手英文是怎样练出来的呀??请教!