473,394 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

output differences

3
I am trying to understand how the following two output statements are different:
let's say I have two integer variables and their values are:
x = 23;
y = 32;

then I have:
System.out.println(x + ' ' + y)
System.out.println(x + " " + y)

How will they appear differently on the screen?
Can anyone help me understand this?
Will the first display as: 23 32
and the second as: 2332 ?
I appreciate any help.
Oct 25 '08 #1
6 1073
Laharl
849 Expert 512MB
Why don't you try printing both and find out? When you've tried it, if you don't understand the output, come back and we'll help you.
Oct 25 '08 #2
JosAH
11,448 Expert 8TB
Here's a hint: realize that you're looking at two different operators, both denoted
by the + symbol, i.e. int+char and int+String; int+char promotes the right operand
to an int so int+int will be performed while for int+String the left operand will be
converted to a String and both Strings will be catenated.

kind regards,

Jos
Oct 25 '08 #3
dukie
3
Here's a hint: realize that you're looking at two different operators, both denoted
by the + symbol, i.e. int+char and int+String; int+char promotes the right operand
to an int so int+int will be performed while for int+String the left operand will be
converted to a String and both Strings will be catenated.

kind regards,

Jos
So, if I'm understanding you correctly, in the first line the operator performs addition, i.e. 23+32+32 and in the second line the two strings are joined together, i.e. 2332? (is the space value for the ASCII character added as I indicated in the first line?)
Oct 25 '08 #4
dukie
3
Why don't you try printing both and find out? When you've tried it, if you don't understand the output, come back and we'll help you.
I am unable to run a program yet, as I can't get my programs to compile. I downloaded the Jgrasp but when I try bto compile the program it gives me an error saying that the javac command must be in the path. I have installed the entire program so I don't know why it's doing that. Do I need to import that command? Please bear with me guys, I'm a total newbie but I am trying very hard to learn and really appreciate the help.
Oct 25 '08 #5
JosAH
11,448 Expert 8TB
So, if I'm understanding you correctly, in the first line the operator performs addition, i.e. 23+32+32 and in the second line the two strings are joined together, i.e. 2332? (is the space value for the ASCII character added as I indicated in the first line?)
Yep, that's correct.

kind regards,

Jos
Oct 25 '08 #6
JosAH
11,448 Expert 8TB
I am unable to run a program yet, as I can't get my programs to compile. I downloaded the Jgrasp but when I try bto compile the program it gives me an error saying that the javac command must be in the path. I have installed the entire program so I don't know why it's doing that. Do I need to import that command? Please bear with me guys, I'm a total newbie but I am trying very hard to learn and really appreciate the help.
It doesn't automagically update your PATH variable: that variable has to contain
the directory where your javac.exe and java.exe are installed. They're both in the
bin directory of your jdk directory (whereever that is stored).

kind regards,

Jos
Oct 25 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sandie Towers | last post by:
We use a number of similar databases and frequently create a new database using a backup restore of another similar database. We try to keep changes between databases in _Additional tables - like...
10
by: Kyle Kolander | last post by:
Got a strange bug going on here... // proper includes and additional code here int x = 2552123; cout << x; This results in output like this: 2,552,123 Same behavior with stringstreams. ...
6
by: Alec MacLean | last post by:
Hi, I've created a small application for our company extranet (staff bulletins) that outputs a list of links to PDF's that are stored in a SQL table. The user clicks a link and the PDF is...
32
by: spibou | last post by:
Is the output of the C preprocessor deterministic ? What I mean by that is , given 2 compilers which conform to the same standard, will their preprocessors produce identical output given as input...
7
by: Steve Hershoff | last post by:
Thanks to this newsgroup I've been pointed to Microsoft's XML Diff & Patch utilities. I've been reading about how I can use the tools to generate a diffgram between two XML documents, and how the...
24
by: tizi_de | last post by:
Hello all, I'm looking for a sample program in C to print out lines not to the standard MS Dos Box but into a different control e.g. text control. Has C the possibility to do printouts to a...
1
by: nriley | last post by:
Hi, I've got a number of doctests which rely on a certain output format, and since I wrote the tests I've changed the output format. Now, almost all the tests fail. What I'd like is if I...
3
by: pradeep | last post by:
Hello, Can any one tell me different functions or properties of javascript which are gives different outputs on different browsers ? Thanks in advance. Bye
3
by: super.raddish | last post by:
Greetings, I am relatively new to, what I would call, advanced XSLT/XPath and I am after some advice from those in the know. I am attempting to figure out a mechanism within XSLT to compare the...
16
by: Okonita via DBMonster.com | last post by:
Hi all, I am comming along with all this Linus/DB2/scripting business...I am no longer scared of it!! (LOL). But, I need to create a .ksh script that does a REORGCHK and output only tables...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.