debugging using assertions
hello,
is there any java game developer here using assert function
i had read the article and still don't know how to use it properly
it said that assert is the best way for debugging
until now i only use the conventional System.out.println for debugging
(do not know how to use any debugger tool)
i'll be very grateful if someone can explain how to use it,
cos i have been through many difficulties using System.out.println to find bugs in my infinitive game loop
thanxx a million
[540 byte] By [
javaweirda] at [2007-9-29 11:37:52]

Using assertions:
- you put expressions in your code like
assert(val > 0);
or
assert (val > 0):"variable val too low";
- you must use java 1.4 or later and compile with javac -source 1.4
- you must run with java -enableassertions
- if the assertion condition is not true an AssertionError is thrown
You should only use assertions to check conditions resulting from you code's execution, never conditions arising out of user input or parameters passed to public methods.
When your code is run without the -enableassertions the assert statements become no-ops.
Hope this helps.