Roy Tock

Ranch Hand
+ Follow
since Jul 16, 2001
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 Roy Tock

First, note that

a3[2] = a2
a3[2][0] = (a3[2])[0] = a2[0] = a1
a3[2][0][0] = (a3[2][0])[0] = a1[0], which is the A13 created in line 4.

A13's toString() is just Object.toString, which is the class name followed by @ followed by the object's hash code, all of which is not null.
17 years ago
Got it; thanks! That explains the previous example, and it also explains why



prints this:

MySubclass: doing something with an object
MySubclass: doing something else

. The doSomething(Object) method is chosen at compile time because the reference is to a MySuperclass, but at run time the decision is made to use the subclass's doSomething(Object). Nasty...but now understandable.
17 years ago
Got that. (That's why I added in the doSomethingElse() method.) And you're right, this isn't truly a polymorphism question.

But why would the compiler choose MySuperclass.doSomething()? I would expect that because the underlying object is actually an instance of MySubclass, the called method would be MySubclass.doSomething(). On top of that, the call in main() has a String argument, which would match MySubclass.doSomething(String) method more specifically than MySuperclass.doSomething(Object).

I'm sure I'm thinking about this incorrectly...but I still don't see it.
17 years ago
I've got a question that I'm hoping one of you can answer. All of this goes into MyMain.java:



Now run. The result:

MySuperclass: doing something
MySubclass: doing something else

Now the $64,000 question: Why is doSomething() from MySuperclass invoked, rather than doSomething from MySubclass?
17 years ago
Three.
Assume they're numbered like this:
---0---
--1-2--
-3-4-5-
6-7-8-9
-------
Then we'll move 0, 6, and 9 like so:
-------
6-1-2-9
-3-4-5-
--7-8--
---0---
I don't know how to prove that we can't do it in two, though.
(Edited to fix spacing.)
[ August 26, 2003: Message edited by: Roy Tock ]
19 years ago
Check out http://wrapper.tanukisoftware.org. It's an open source product, hosted by SourceForge, that wraps a Java program with a Windows service.
19 years ago
A little googling...and voila! This is no fun...but it's been haunting you. You don't have to peek
the answer
19 years ago
Hmmm... under Windows, using cygwin's "od -t x2 blah.class" to show me what's in the file, I get "feca beba".
Not nearly as cool sounding as CAFEBABE.
[ August 14, 2003: Message edited by: Roy Tock ]
19 years ago
Even more minimalist, this worked:
set PATH=
set CLASSPATH=
C:\j2sdk1.4.1_03\bin\javac PracThread.java
C:\j2sdk1.4.1_03\bin\java PracThread
19 years ago
On my box, I successfully compiled and ran the program with this:
set PATH=C:\j2sdk1.4.1_03\bin
set CLASSPATH=
javac PracThread.java
java PracThread
Rather than trying to pare down your classpath & path, maybe try starting from scratch?
19 years ago
Well, I'd consider myself a common person... Lemme see...
Mozilla is my favorite program. I'm using it now!
I really like OpenOffice; it has saved me lots of money.
Real VNC is a necessity for any household or business having Windows PCs in multiple locations.
My favorite dictionary is at the Mirriam-Webster website. Lots of good stuff there.
My favorite utility for organizing my life is my PDA.
And my favorite "utility" for learning about how to learn Java is here.
19 years ago