You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Magnus Jansson <Ad...@vaddo.fhsk.se> on 2001/09/17 09:24:47 UTC

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


AW: Is this the way to do it?

Posted by Reto Badertscher <rb...@i-netsystems.com>.
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:Admin@vaddo.fhsk.se]
Gesendet: Montag, 17. September 2001 09:25
An: tomcat-user@jakarta.apache.org
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



RE: Is this the way to do it?

Posted by Wouter Boers <Wo...@MphasiS.com>.
Java does have a slimmed down version of the Object of most frequently used
primitive types

boolean -> Boolean
int	  -> Interger
float   -> Depends what you want BigInteger, Double etc etc

Look at the JavaDoc documentation of java int the java.lang.*, usually there
is a toInt() method to convert the Object to the desired primitive type.

So to answer you question:
boolean booldans = false;

is probably easier.

Wouter

-----Original Message-----
From: Magnus Jansson [mailto:Admin@vaddo.fhsk.se]
Sent: 17 September 2001 09:25
To: tomcat-user@jakarta.apache.org
Subject: 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