Skip to content

Commit 3a5edf7

Browse files
authored
Shows string concatenation
Demonstrates the use of the string concatenation operator and the automatic conversion of an integer to a string.
1 parent 825ffee commit 3a5edf7

File tree

1 file changed

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

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//********************************************************************
2+
// Facts.java Author: Lewis/Loftus
3+
//
4+
// Demonstrates the use of the string concatenation operator and the
5+
// automatic conversion of an integer to a string.
6+
//********************************************************************
7+
public class Facts
8+
{
9+
//-----------------------------------------------------------------
10+
// Prints various facts.
11+
//-----------------------------------------------------------------
12+
public static void main(String[] args)
13+
{
14+
// Strings can be concatenated into one long string
15+
System.out.println("We present the following facts for your "
16+
+ "extracurricular edification:");
17+
System.out.println();
18+
// A string can contain numeric digits
19+
System.out.println("Letters in the Hawaiian alphabet: 12");
20+
// A numeric value can be concatenated to a string
21+
System.out.println("Dialing code for Antarctica: " + 672);
22+
System.out.println("Year in which Leonardo da Vinci invented "
23+
+ "the parachute: " + 1515);
24+
System.out.println("Speed of ketchup: " + 40 + " km per year");
25+
}
26+
}

0 commit comments

Comments
 (0)