🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17750

Re: Check if object doesn't exist???

#17750
From: Richard Wilkman
Date: Thu, 08 Oct 1998 00:00
50 lines
1818 bytes
Adam:

I'd do this a little differently and make zObject a member of the
class and do something like:

public class foo{
  static Object zObject = null;

... constructor, etc. ....

  public static Object getZObject(){
    if(zObject == null)
       return new Object();  // stick in the correct constructor here
    return zObject;   
  }

The way I've outlined it you'd only have one of your object in use. 
If you don't mind having multiples you could remove the static
modifier for the object.

-Rich

Adam Silverthorne wrote:
> 
> Hi, I have a simple problem... I want to create an object IF it doesn't
> already exist.  How can I test for this?
> 
> For example
> 
> (if zObject != exit){
>     NewObject zObject = new NewObject();
> }
> 
> -Adam
> doogie@slip.net

-- 

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Rich Wilkman
Senior Quality Assurance Engineer
Borland JBuilder Team

If you see something that looks like an opinion up there,
it's mine and mine alone.

Mail sent to me from the newsgroups won't bounce but will
be ignored.  If I have time, I'll respond, but you  have
a better chance if you confine your posts to the newsgroups
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Technical Details
Message-ID: <361CD5CD.69B26C77@inprise.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <361BF7D5.D41D6F8C@slip.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,8738f3916106a60c
X-Google-Attributes: gidf74b3,public
From: Richard Wilkman <rwilkman@inprise.com>
Subject: Re: Check if object doesn't exist???
Date: 1998/10/08
Message-ID: <361CD5CD.69B26C77@inprise.com>
X-Deja-AN: 399017029
Content-Transfer-Encoding: 7bit
References: <361BF7D5.D41D6F8C@slip.net>
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language