Sorry, but I think that he has created several instances of a Boolean
with a "false" value.

I know that if you use the constants Boolean.TRUE and Boolean.FALSE you
will not create any new instances, but I think if you use "new" you create
a new instance (which is why Boolean should not have had a public
constructor, but rather a static getInstance() method, IMNSHO).

> Hi Magnus,
> 
> only two instances of Boolean exists:
> - TRUE
> - FALSE
> 
> your different Booleans just hold a reference on one of the two.
> 
> Reto
> -----Ursprüngliche Nachricht-----
> Von: Magnus Jansson [mailto:[EMAIL PROTECTED]]
> Gesendet: Montag, 17. September 2001 09:25
> An: [EMAIL PROTECTED]
> Betreff: Is this the way to do it?
> 
> 
> Hi I'm a newbie at both jsp and java. My question is:
> 
> Is this the way to set a (in this case) a Boolean value? This seems for me
> who is a Pascal programmer as I create a new instance of the Boolean object
> everytime I set a new value?
> 
> Besides it is a lot of code to write? Can I set the value of the boolean in
> any other way????????
> 
> I have the same problem in the other objects of the primitive types (Integer
> for example)
> 
> <snip>
> 
>   Boolean BoolDans = new Boolean(false);
>   Boolean BoolAllman = new Boolean(false);
>   Boolean BoolFof = new Boolean(false);
>   Boolean BoolTextil = new Boolean(false);
>   Boolean BoolHp = new Boolean(false);
> 
>   if (request.getParameter("IntresseDans") != null) {BoolDans = new
> Boolean(true);};
>   if (request.getParameter("IntresseAllman") != null) {BoolAllman = new
> Boolean(true);};
>   if (request.getParameter("IntresseFof") != null) {BoolFof = new
> Boolean(true);};
>   if (request.getParameter("IntresseTextil") != null) {BoolTextil = new
> Boolean(true);};
>   if (request.getParameter("IntresseHp") != null) {BoolHp = new
> Boolean(true);};
> 
> </snip>
> 
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
> - - - - - - -
> Magnus Jansson
> IT-Manager
> Väddö folkhögskola
> 760 40 Väddö
> Sweden
> 
> Phone: +46 (0) 176-528 00
> Cellular: +46 (0) 70-370 33 16
> Fax: +46 (0) 176-528 28
> http://www.vaddo.fhsk.se (work)
> http://www.jason.pp.se (private)
> ICQ: 52797837
> 
> 


-- 
D. Jay Newman                      !  // The worst possible legal hashCode
[EMAIL PROTECTED]                !  public int hashCode() { return 42;}
http://www.sprucegrove.com/~jay/   !    -- _Effective Java_

Reply via email to