String Concatenation Objectives

Slides:



Advertisements
Similar presentations
Introduction to Computing Concepts Note Set 7. Overview Variables Data Types Basic Arithmetic Expressions ▫ Arithmetic.
Advertisements

©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
Computer Science 1620 Arithmetic. C++ Math we have seen how to use numbers in our program to represent data however, we can also manipulate this data.
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
Program Elements We can now examine the core elements of programming (as implemented in Java) We focuse on: data types variable declaration and use, constants.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
1 Expressions, Operators Expressions Operators and Precedence Reading for this class: L&L, 2.4.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
1 Character Strings and Variables Character Strings Variables, Initialization, and Assignment Reading for this class: L&L,
WRITING BASIC SQL SELECT STATEMENTS Lecture 7 1. Outlines  SQL SELECT statement  Capabilities of SELECT statements  Basic SELECT statement  Selecting.
***** SWTJC STEM ***** Chapter 2-3 cg 29 Java Operators Recall Java’s programming components: Packages - Collection of classes (Programs) Classes - Collections.
1 Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class:
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
2440: 211 Interactive Web Programming Expressions & Operators.
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Program Statements Primitive Data Types and Strings.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-WesleyCopyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
ORDER OF OPERATIONS x 2 Evaluate the following arithmetic expression: x 2 Each student interpreted the problem differently, resulting in.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Assignment Statements Operator Precedence. ICS111-Java Programming Blanca Polo 2 Assignment, not Equals  An assignment statement changes the value of.
OOP with Java, David J. Barnes Adding Sequential Behavior1 Adding Behavior Previous class definitions have passively maintained attributes. Active behavior.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Order of Operations.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Mathematical Calculations in Java Mrs. G. Chapman.
Building Java Programs Primitive Data and Definite Loops.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
1-2 Order of Operations and Evaluating Expressions.
Chapter 2 topics Concept # on Java Subset Required for AP Exam print and println10. Testing of output is restricted to System.out.print and System.out.println.
Operators and Expressions. 2 String Concatenation  The plus operator (+) is also used for arithmetic addition  The function that the + operator performs.
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
Doing math In java.
Chapter 2 print / println String Literals Escape Characters Variables / data types.
1 Chapter 2 Basic SQL SELECT Statements. 2 Chapter Objectives Distinguish between an RDBMS and an ORDBMS Identify keywords, mandatory clauses, and optional.
© 2007 Pearson Addison-Wesley. All rights reserved2-1 Character Strings A string of characters can be represented as a string literal by putting double.
1 Data and Expressions Chapter 2 In PowerPoint, click on the speaker icon then the “play” button to hear audio narration.
CSCI 1100/1202 January 14, Abstraction An abstraction hides (or ignores) the right details at the right time An object is abstract in that we don't.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Chapter 2 1.What is the difference between print / println 2.What are String Literals 3.What are the Escape Characters for backslash, double quotataions,
CSCI 1100/1202 January 18, Arithmetic Expressions An expression is a combination of operators and operands Arithmetic expressions compute numeric.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
© 2004 Pearson Addison-Wesley. All rights reserved August 27, 2007 Primitive Data Types ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
Chapter 2 Basic Computation
Primitive Data Types August 28, 2006 ComS 207: Programming I (in Java)
CSC 1051 – Data Structures and Algorithms I
Multiple variables can be created in one declaration
Type Conversion, Constants, and the String Object
Section 3.2c Strings and Method Signatures
Java Programming: From Problem Analysis to Program Design, 4e
Writing Basic SQL SELECT Statements
Data Types, Identifiers, and Expressions
Chapter 2: Basic Elements of Java
Arithmetic Expressions & Data Conversions
Chapter 2 Create a Chapter 2 Workspace Create a Project called Notes
Writing Basic SQL SELECT Statements
Expressions.
Data Types and Expressions
Chapter 2 Programming Basics.
See requirements for practice program on next slide.
Arithmetic Operations
7 – Variables, Input and Output
Instructor: Alexander Stoytchev
Data Types and Expressions
Arithmetic Expressions & Data Conversions
Data Types and Expressions
Presentation transcript:

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.

String Concatenation AP Computer Science

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.

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

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

String Concatenation System.out.println (“24 and 45 concatenated: “ + 24 + 45); Output: 24 and 45 concatenated: 2445 System.out.println (“24 and 45 added: “ + (24 + 45)); 24 and 45 added: 69

And then finally…. Output: 100 is equal to one hundred System.out.println (50 + 50 + “ is equal to one hundred”); Output: 100 is equal to one hundred System.out.println (50 + 50 + “ is equal to one hundred ” + 50 + 50); 100 is equal to one hundred 5050