Jake Westphal

Greenhorn
+ Follow
since Apr 10, 2002
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 Jake Westphal

To practice algorithms, I've been using some technical interview web sites for good ideas. Here is one site I use: Ace The Interview - Technical Questions
The answers are posted in C/C++, but I code the answers in Java. They have some good algorithm questions there. Another site I use is:
Technical Interview Questions. The questions can usually be solved and coded within a few hours (depending on your Java proficiency).
One other suggestion I have is to port something? Do you have an old application you developed that you could port to Java? While you wouldn't be working with algorithms, you would certainly learn the API!!
Good luck,
Jake
18 years ago
I only just started learning Java, so my advice may be wrong -- but...
Are you sure that the element returned by nextElement CAN be cast to an Integer type?
According to the Java docs, a ClassCastException is "thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. For example, the following code generates a ClassCastException:
"
If the objects in Vector v are not Integers and cannot be cast to Integers, you'll get this exception. I'm not sure if you can cast the primitive type int to Integer.
Hope that helps -- Jake
18 years ago
A note on OO design with regard to the code above, I read a good article about using inner classes to remove large switch or if/if else statements. It helped me understand good, real world uses for anonymous classes.
It would change the code above so that each button has its own implementation of actionPerformed, and thus, the large if/if statement in actionPerformed is not needed.
Here is the article:
Inner Classes
18 years ago
If you have an anonymous inner class that defines new methods not available in the superclass, can you call those methods?
For example:

The code generates a compiler error because the Canis class knows nothing of bitesHand().
My question is, is there anyway to call bitesHand() outside of the inner class? Must your anonymous inner classes only implement/override the existing functions from the superclass or interface?
Thanks.
Molly
18 years ago