E
Eric
Hi all,
I've been trying to get my mind around a certain setup, and am sure I'm
missing something. I was hoping someone could shed some light on it.
Say you had a simple library type application, and you set it up so
that all books would be children of a Book superclass:
public class Book {}
public class Philosophy extends Book {
static int DeweyDecimal = 601;
}
public class JavaProgramming extends Book {
static int DeweyDecimal = 005;
}
public class WebstersDictionary extends Book {
static int DeweyDecimal = 903;
}
Now, if I had an array I'd created off all the classes of books (e.g.
Book[] books = {Philosophy.class, JavaProgramming.class,
WebstersDictionary.class}) how would I go about getting the
DeweyDecimal number of one of the types of books without instantiating
them?
I'd be happy to do so through a method, or add anything to the parent
class, but although I've looked at reflection and thought about it a
fair bit, I haven't been able to figure out a way to do this...
Any thoughts?
Eric
I've been trying to get my mind around a certain setup, and am sure I'm
missing something. I was hoping someone could shed some light on it.
Say you had a simple library type application, and you set it up so
that all books would be children of a Book superclass:
public class Book {}
public class Philosophy extends Book {
static int DeweyDecimal = 601;
}
public class JavaProgramming extends Book {
static int DeweyDecimal = 005;
}
public class WebstersDictionary extends Book {
static int DeweyDecimal = 903;
}
Now, if I had an array I'd created off all the classes of books (e.g.
Book[] books = {Philosophy.class, JavaProgramming.class,
WebstersDictionary.class}) how would I go about getting the
DeweyDecimal number of one of the types of books without instantiating
them?
I'd be happy to do so through a method, or add anything to the parent
class, but although I've looked at reflection and thought about it a
fair bit, I haven't been able to figure out a way to do this...
Any thoughts?
Eric