Download presentation
Presentation is loading. Please wait.
1
String Concatenation Objectives
Concatenate strings into one long string. Concatenate strings and numbers. Understand the algebraic rules that define the order in which operators get evaluated.
2
String Concatenation AP Computer Science
3
String Literals A Character string is an object in Java,defined by the String class. Strings are an important part of computer programming The string literal is what appears inside the double quotations marks.
4
String Concatenation The plus operator (+) is also used for arithmetic addition The function that the + operator performs depends on the type of the information on which it operates If both operands are strings, or if one is a string and one is a number, it performs string concatenation If both operands are numeric, it adds them The + operator is evaluated left to right Parentheses can be used to force the operation order
5
String Concatenation System.out.println (“We Present the following facts for your “ “extracurricular edification:”); Output: We present the following facts for your extracurricular edification: System.out.println (“Dialing code for Antartica: “ + 672); Dialing code for Antartica: 672
6
String Concatenation System.out.println (“24 and 45 concatenated: “ ); Output: 24 and 45 concatenated: 2445 System.out.println (“24 and 45 added: “ + ( )); 24 and 45 added: 69
7
And then finally…. Output: 100 is equal to one hundred
System.out.println ( “ is equal to one hundred”); Output: 100 is equal to one hundred System.out.println ( “ is equal to one hundred ” ); 100 is equal to one hundred 5050
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.