Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f5142ee

Browse files
Shows difference between addition and concatenation
Concatenates and adds two numbers and prints the results.
1 parent 3a5edf7 commit f5142ee

File tree

1 file changed

+17
-0
lines changed
  • textbook work/java software solutions/2. Data and Expressions

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//********************************************************************
2+
// Addition.java Author: Lewis/Loftus
3+
//
4+
// Demonstrates the difference between the addition and string
5+
// concatenation operators.
6+
//********************************************************************
7+
public class Addition
8+
{
9+
//-----------------------------------------------------------------
10+
// Concatenates and adds two numbers and prints the results.
11+
//-----------------------------------------------------------------
12+
public static void main(String[] args)
13+
{
14+
System.out.println("24 and 45 concatenated: " + 24 + 45);
15+
System.out.println("24 and 45 added: " + (24 + 45));
16+
}
17+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /