Wayne Bell wrote:
Steve,

First of all, you forced both the second and third lines to characters by having characters in both lines. So they would both produce '22'.


Well, I actually ran a separate test at the same time:

     System.out.println("In main");
     System.out.println("2 + quoted 2 = " + 2 + "2");
     System.out.println("quoted 2 + 2 = " + "2" + 2);
     System.out.println("Leaving main");

and got the same results.

And with

 System.out.println("2 + 2 = " + 2 + 2);

you still get

  2 + 2 = 22



But to add to the confusion, here is the simple program that I wrote:

/* REXX */ X = 2 + "2"; Y = "2" + 2; SAY "Second 2 Quoted:" SAY X; SAY "First 2 Quoted:" SAY Y;
With the result:

Second 2 Quoted:
4 First 2 Quoted: 4
Both converted to numerics!!  I'm confused!

As someone pointed out, REXX looks first to see
if a string can be considered a number; if so,
it will use the numeric interpretation; in Java,
"+" in a String context is concatenation, so Java
tries to treat the data as String; in REXX, the
concatenation operator is || or simply juxtaposition;
seeing the "+", REXX looks to do a numeric operation
of ADD, so it treats the values as numbers.



Wayne Bell
UniGroup, Inc.


Not true; both produce "22":

     System.out.println("In main");
     System.out.println("2 + quoted 2 = " + (2 + "2"));
     System.out.println("quoted 2 + 2 = " + ("2" + 2));
     System.out.println("Leaving main");

yields:

In main
2 + quoted 2 = 22
quoted 2 + 2 = 22
Leaving main



Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.
######################################################################## This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. This footnote also confirms that this email message has been swept for the presence of computer viruses. UNIGROUPINC.COM ########################################################################

Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-393-8716
http://www.trainersfriend.com

  z/OS Application development made easier
    * Our classes include
       + How things work
       + Programming examples with realistic applications
       + Starter / skeleton code
       + Complete working programs
       + Useful utilities and subroutines
       + Tips and techniques

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to