You may try this out:

-define a field for the class ; say,
    public static int counter;
-define a exception class,say
  public static CounterException extends Exception
-declare a constructor that throws CounterException
  and rethrow the exception if counter>1
-try to define a main method that tries to create more than one exception.

-br


----- Original Message -----
From: Sanjay Vashisht <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 10, 2000 10:12 AM
Subject: offtopic: Can i have only one object for a class


> Hi All
>
> This is an off-topic but an interesting question?
> can i have only one object for a class defined. If user try to create
> one more object that should be an Exception or error condition.
>
> Thanks in Advance.
>  Rgds
> Sanjay
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to