Top.Mail.Ru
September 1st, 2005 - Java developers — LiveJournal
? ?

Java developers

September 1st, 2005

09:23 am - lemmywinks30

Can someone tell me why this is wrong?

class Base { }
class Sub extends Base { }
class Sub2 extends Base { }

public class CEx {
public static void main(String args[]){
Base b = new Base();
Sub s = (Sub) b;
}
}

The answer is 'Runtime Exception'...Why can't we cast a base into a sub? I thought if you move down the hierarchy a cast is required and all is well.

03:51 pm - jaq - JDK update and PATH on Windows

I’ve discovered the answer to a problem we were having with things running with an unexpected version of Java. When the JDK installer is run, it can install two JREs – a ‘private’ one in the same place as you choose to put the JDK (e.g. C:\java\jdk1.5.0_04\jre on my machine), and also a ‘public’ one in a standard location (e.g. C:\Program Files\Java\jre1.5.0_04).

However there is an extra effect when installing the public JRE – it copies java.exe (and related commands) into the Windows System folder (e.g. C:\WINDOWS\system32). Since this folder usually appears at the start of the PATH environment variable it means that the copied java is likely to be picked up first by anything that uses the PATH, and this isn’t what I expected.

Taken from: http://java.sun.com/j2se/1.5.0/install-windows.html

(What, read documents before installing it? Never!)
Powered by LiveJournal.com