Can someone tell me why this program, when run under
Linux, prints d = 0 (ie. the variable d isn't being
initialized as expected)? According to Bruce Eckel's
book, which is the only reference I have available to
me, d should be initialized to 1, so I suspect this
may be a JVM bug ...
Rich.
---------------------------------------------------------
/* SuperClass.java */
public abstract class SuperClass
{
protected SuperClass ()
{
method ();
}
protected abstract void method ();
}
---------------------------------------------------------
---------------------------------------------------------
/* DerivedClass.java */
public class DerivedClass extends SuperClass
{
public int d = 1;
public DerivedClass ()
{
super ();
}
protected void method ()
{
System.out.println ("d = " + d);
}
public static void main (String[] args)
{
DerivedClass derivedClass = new DerivedClass ();
}
}
---------------------------------------------------------
$ java -version
java version "1.1.6"
$ java DerivedClass
d = 0
--
- Richard Jones. Linux contractor London and SE areas. -
- Very boring homepage at: http://www.annexia.demon.co.uk/ -
- You are currently the 1,991,243,100th visitor to this signature. -
- Original message content Copyright (C) 1998 Richard Jones. -