Sérgio Lopes

Greenhorn
+ Follow
since Jan 25, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sérgio Lopes

hi everybody

I was looking at the exam objectives and noted that 3 topics disappeared:

http://www.sun.com/training/catalog/courses/CX-310-065.xml

the three topics that were there before are:

"Develop code that declares both static and non-static methods, and - if appropriate - use method names that adhere to the JavaBeans naming standards. Also develop code that declares and uses a variable-length argument list."

"Develop code that serializes and/or de-serializes objects using the following APIs from java.io: DataInputStream, DataOutputStream, FileInputStream, FileOutputStream, ObjectInputStream, ObjectOutputStream and Serializable."

"Given a scenario, write code that makes appropriate use of wait, notify, or notifyAll."

and they also disappeared from SCJP 5 too:

http://www.sun.com/training/catalog/courses/CX-310-055.xml

does anyone know anything about this?

The run method is defined primarily in Runnable, a very simple interface. The Thread class have this method because Thread implements Runnable. But any other class that choose to implement Runnable will also have the run method.

And Object doesn't implement Runnable and doesn't have the run method.
Catching an AssertionError is legal and behaves as a normal try/catch block. You can catch any Throwable anytime. Your code is correct, it compiles and runs perfectly, printing the output you posted.

But it's not very wise to catch assert errors, because there's nothing you can do inside the catch block. Asserts should be used to test code invariants and an assertion error usually says that there is a problem with your code. The best practice with asserts is to let the error stop de program (without catching them) and then fixing the problem in your code.

That is, you can catch AssertionError and nothing special occurs, but it's a bad practice.
There's nothing more you can do to improve reflection performance in your code
15 years ago
You can run the JVM with -verbose:gc and -XX:+PrintGCDetails to see more details about memory usage an memory freeing. Of course you can increase Xmx and Xms but maybe you have some kind of memory leak on your application.
15 years ago
And you can use the shortcut option -cp instead of -classpath
15 years ago
Thinking In Java is the best one I can recommend...
15 years ago