Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t Inserts a tab in the.

Slides:



Advertisements
Similar presentations
This Time Whitespace and Input/Output revisited The Programming cycle Boolean Operators The “if” control structure LAB –Write a program that takes an integer.
Advertisements

Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
Copyright 2008 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: self-check: #1-14.
Lecture 3: Strings, Screen Output, and Debugging Yoni Fridman 7/2/01 7/2/01.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 1: Introduction to Java Programming.
Characters and Strings. Characters In Java, a char is a primitive type that can hold one single character A character can be: –A letter or digit –A punctuation.
1 Character Strings and Variables Character Strings Variables, Initialization, and Assignment Reading for this class: L&L,
Copyright 2013 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
1 Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may.
Copyright 2008 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: self-check: #1-14.
Introducing Java.
Towson University COSC 236
2.2 Information on Program Appearance and Printing.
Topic 2 Java Basics “When a programming language is created that allows programmers to program in simple English, it will be discovered that programmers.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram.
Program Statements Primitive Data Types and Strings.
Output in Java Hello World!. Structure of a Java Program  All Java files in ICS3U1 have the following structure: class HelloWorld { }  Notice the open.
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Can we talk?. In Hello World we already saw how to do Standard Output. You simply use the command line System.out.println(“text”); There are different.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) public static void main(String[]
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
Chapter 3 Introduction To Java. OBJECTIVES Packages & Libraries Statements Comments Bytecode, compiler, interpreter Outputting print() & println() Formatting.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
Lab 01-2 Objectives:  Writing a Java program.  How to send output to the command line console.  Learn about escape sequences.  Learn how to compile,
Chapter 2 print / println String Literals Escape Characters Variables / data types.
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.
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,
Objective Write simple computer program in C++ Use simple Output statements Become familiar with fundamental data types.
Copyright 2010 by Pearson Education CSE 142, Fall 2011 Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
17-Mar-16 Characters and Strings. 2 Characters In Java, a char is a primitive type that can hold one single character A character can be: A letter or.
Copyright 2010 by Pearson Education CSE 142, Spring 2012 Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading: 1.1 -
Welcome to CSE 142! Zorah Fung University of Washington, Summer Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
CSc 127a/110, Autumn 2016 Lecture 1: Introduction; Basic Python Programs.
Lecture 4 – Scanner & Style
Zorah Fung University of Washington, Winter 2016
Lecture 1: Introduction; Basic Python Programs
Topic Pre-processor cout To output a message.
CSC201: Computer Programming
Welcome to CSE 142! Whitaker Brand and Benson Limketkai
Chapter 2, Part I Introduction to C Programming
CSE 190D, Winter 2013 Building Java Programs Chapter 1
Lecture 7: Input and Miscellaneous
OUTPUT STATEMENTS GC 201.
Benson Limketkai and Marty Stepp University of Washington, Spring 2010
Benson Limketkai University of Washington, Spring 2011
Building Java Programs
Whitaker Brand University of Washington, Winter 2018
Chapter 2 Create a Chapter 2 Workspace Create a Project called Notes
Topic 2 Java Basics “When a programming language is created that allows programmers to program in simple English, it will be discovered that programmers.
CSc 110, Spring 2018 Lecture 2: Functions.
Building Java Programs
Welcome to CSE 142!.
CSE 142, Summer 2012 Building Java Programs Chapter 1
Building Java Programs
Nate Brunelle Today: Strings, Type Casting
CSE 142, Spring 2012 Building Java Programs Chapter 1
Lecture 1: Introduction; Basic Python Programs
Review of Previous Lesson
Output Manipulation.
CSE 142, Winter 2014 Building Java Programs Chapter 1
Python Lessons 7 & 8 Mr. Husch.
Introduction to Programming - 1
CSC 1051 – Data Structures and Algorithms I
Consult America Technology Consulting Services
© A+ Computer Science - Basic Java © A+ Computer Science -
Odds and Ends.
Presentation transcript:

Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t Inserts a tab in the text at this point. \n Inserts a newline in the text at this point. \" Inserts one double quote in the text at this point. \’ Inserts one single quote in the text at this point. \\ Inserts a backslash character at this point \r Moves cursor to start of line/overwrites as it types \b Inserts a backspace at this place Example: System.out.println("\\hello\nhow\tare \"you\"?\\\\"); Output: \hello how are "you"?\\

Question How many visible characters does the following println statement produce when run? System.out.println("\t\nn\\\t\"\tt"); 1 2 3 4

Practice Program 1 What sequence of println statements will generate the following output? This program prints the first lines of the song "slots". "She lives in a trailer" "On the outskirts 'a Reno" "She plays quarter slots in the locals casino."

Practice Program 2 What sequence of println statements will generate the following output? A "quoted" String is 'much' better if you learn the rules of "escape sequences." Also, "" represents an empty String. Don't forget to use \" instead of " ! '' is not the same as "

Practice Program 3 What is the output of the following println statements? System.out.println("\ta\tb\tc"); System.out.println("\\\\"); System.out.println("'"); System.out.println("\"\"\""); System.out.println("C:\nin\the downward spiral"); 5

Answer to Practice Program 3 Output of each println statement: a b c \\ ' """ C: in he downward spiral

Practice Program 4 Write a println statement to produce this output: / \ // \\ /// \\\

Answer to Practice Program 4 println statement to produce the line of output: System.out.println("/ \\ // \\\\ /// \\\\\\");

Internet Transfer Project To whom was the Internet oversight transferred (instead of the USA)? What entities (nations represented, companies represented, others) make up the group to whom the transfer was made? Who is responsible for the transfer? When did the transfer occur? What are the expected or potential changes in internet/information and use (positives and negatives)?