
Signature
Please don't reply to the e-mail address above.
Use instead: stefan DOT waldmann AT web DOT de
[..]
> public class VectorOfLifeForms {
> public String toString() {
[quoted text clipped - 6 lines]
> elements, calls their toString() method and returns a String composed
> the String representations of all your life forms.
heh. now i know :) thanks.
> (By the way, your Vector is named strangely - only constants which
> cannot be changed should be named in uppercase. For a Vector that
> doesn't make much sense...)
my thinking is that LIST_OF_LIFE_FORMS is a singleton, therefore in
all caps. yes/no? the rest i'll have to think about.
[..]
thanks,
javac@mail.com
http://www.geocities.com/cjavacjava
Ryan Stewart - 06 May 2004 00:17 GMT
> [..]
> > public class VectorOfLifeForms {
[quoted text clipped - 16 lines]
> my thinking is that LIST_OF_LIFE_FORMS is a singleton, therefore in
> all caps. yes/no? the rest i'll have to think about.
No. A Vector is not a singleton. A singleton is a class of which there will
be at most one instance. That was a confusing sentence. Turn it around.
There can only ever be one instance of a singleton class. For example:
public class Singleton {
private static Singleton instance;
private Singleton() {}
public Singleton getInstance() {
if (instance == null) {
instance = new Singleton();
}
return instance;
}
}
That's a simple, non-thread-safe singleton class and, coincidentally, an
example of a typical getInstance method.
javac - 06 May 2004 23:02 GMT
i did some reading on singleton, think i'm ok with that.
also, i fixed up the toString methods. i was confused by my own code,
i had System.out in the toString, _and_ was returning a String -- a
mess. fixed it up, i think :)
thanks all,
javac@mail.com
http://www.geocities.com/cjavacjava/