Table of Contents Date(s) Title/Topic Page #s. Abstraction

Similar documents
CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI

Data and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:

A variable is a name for a location in memory A variable must be declared

We now start exploring some key elements of the Java programming language and ways of performing I/O

Learning objectives: Objects and Primitive Data. Introduction to Objects. A Predefined Object. The print versus the println Methods

Variables, Constants, and Data Types

Chapter 2: Data and Expressions

Chapter. Let's explore some other fundamental programming concepts

Chapter 2: Data and Expressions

Chapter 2: Data and Expressions

Constants. Why Use Constants? main Method Arguments. CS256 Computer Science I Kevin Sahr, PhD. Lecture 25: Miscellaneous

COMP 202. Built in Libraries and objects. CONTENTS: Introduction to objects Introduction to some basic Java libraries string

Introduction to Java Chapters 1 and 2 The Java Language Section 1.1 Data & Expressions Sections

2 rd class Department of Programming. OOP with Java Programming

Expressions and Casting. Data Manipulation. Simple Program 11/5/2013

First Java Program - Output to the Screen

Expressions and Casting

Lecture 3: Variables and assignment

CMPT 125: Lecture 3 Data and Expressions

For the course, we will be using JCreator as the IDE (Integrated Development Environment).

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Lecture 2 Tao Wang 1

Getting started with Java

Programming for Engineers Introduction to C

An overview of Java, Data types and variables

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Chapter 2, Part I Introduction to C Programming

Basics of Java Programming

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

Building Java Programs

4 Programming Fundamentals. Introduction to Programming 1 1

Full file at

Building Java Programs

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

objectives chapter Define the difference between primitive data and objects. Declare and use variables. Perform mathematical computations.

2: Basics of Java Programming

CS313D: ADVANCED PROGRAMMING LANGUAGE

Chapter 2: Using Data

Chapter 2 Exercise Solutions

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

What we will do today Explain and look at examples of. Programs that examine data. Data types. Topic 4. variables. expressions. assignment statements

4. Inputting data or messages to a function is called passing data to the function.

Full file at

Program Elements -- Introduction

CS112 Lecture: Working with Numbers

Professor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators

Introduction To Java. Chapter 1. Origins of the Java Language. Origins of the Java Language. Objects and Methods. Origins of the Java Language

Strings, Strings and characters, String class methods. JAVA Standard Edition

2 nd Week Lecture Notes

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

What did we talk about last time? Examples switch statements

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

Fundamentals of Programming Session 4

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

CPS122 Lecture: From Python to Java

Computer Science is...

TUGCE KEMEROZ - ASLI OZKAN - AYSE TARTAN. Week 12/02/ /02/2007 Lecture Notes:

Arithmetic Expressions in C

Building Java Programs. Chapter 2: Primitive Data and Definite Loops

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

COMP 202 Java in one week

Chapter 2: Using Data

Chapter 2. Lexical Elements & Operators

VARIABLES, DATA TYPES,

Programming Languages & Translators. XML Document Manipulation Language (XDML) Language Reference Manual

CS112 Lecture: Primitive Types, Operators, Strings

Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

Java Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

COMP 110 Introduction to Programming. What did we discuss?

B.V. Patel Institute of BMC & IT, UTU 2014

Visual C# Instructor s Manual Table of Contents

CS111: PROGRAMMING LANGUAGE II

Some Computer Preliminaries

Chapter 2 Working with Data Types and Operators

CS110: PROGRAMMING LANGUAGE I

ECE 122 Engineering Problem Solving with Java

Basic Computation. Chapter 2

3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.

Chapter 3 Structure of a C Program

CS 112 Introduction to Programming

COMP-202 Unit 2: Java Basics. CONTENTS: Printing to the Screen Getting input from the user Types of variables Using Expressions and Variables

Admin. CS 112 Introduction to Programming. Recap: Java Static Methods. Recap: Decomposition Example. Recap: Static Method Example

Chapter 02: Using Data

Introduction to Computer Science I

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CS 106 Introduction to Computer Science I

Building Java Programs

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript

Primitive Data, Variables, and Expressions; Simple Conditional Execution

HUDSONVILLE HIGH SCHOOL COURSE FRAMEWORK

Variables and Literals

Objects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003

A Java program contains at least one class definition.

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings

Transcription:

Table of Contents Date(s) Title/Topic Page #s 9/10 2.2 String Literals, 2.3 Variables and Assignment 34-35 Abstraction An abstraction hides (or suppresses) the right details at the right time An object is abstract in that we don't have to think about its internal details in order to use it For example, we don't have to know how the println method works in order to invoke it A human being can manage only seven (plus or minus 2) pieces of information at one time But if we group information into chunks (such as objects) we can manage many complicated pieces at once Classes and objects help us write complex software

WWK p. 9 or 10 abstraction an object is an abstraction the user doesn't care about how it works ex: println Set up p. 34 for HW and p. 35 for Cornell notes HW 2.2 String Literals 34 35

Go to Google Classroom and download the.txt files I shared with you. Copy and paste it (all text below "Listing") into Dr. Java and compile it. Alter the code to understand what it does. Listing 201: difference between print and println Listing 202: use of the string concatenation and automatic conversion of an integer to a string Listing 203: difference between the addition and string concatenation operators Listing 204: escape sequences Listing 205: declaration, initialization, and use of an integer variable Listing 206: use of an assignment statement to change the value stored in a variable Character Strings Every character string is an object in Java, defined by the String class Every string literal, delimited by double quotation marks, represents a String object The string concatenation operator (+) is used to append one string to the end of another It can also be used to append a number to a string A string literal cannot be broken across two lines in a program

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 p. 35 2.2 String Literals string literal string concatenation a string of characters that appear in double quotation marks + is the operator adds one string to another

Escape Sequences What if we wanted to print a double quote character? The following line would confuse the compiler because it would interpret the second quote as the end of the string System.out.println ("I said "Hello" to you."); An escape sequence is a series of characters that represents a special character An escape sequence begins with a backslash character (\), which indicates that the character(s) that follow should be treated in a special way System.out.println ("I said \"Hello\" to you."); p. 35 2.2 String Literals escape \n newline sequences \" double quote \\ backslash

Escape Sequences

Variables Assignment

Constants A constant is an identifier that is similar to a variable except that it holds one value while the program is active The compiler will issue an error if you try to change the value of a constant during execution In Java, we use the final modifier to declare a constant final int TAX_RATE = 0.0675; Constants: > give names to otherwise unclear literal values > facilitate updates of values used throughout a program > prevent inadvertent attempts to change a value p. 35 2.2 String Literals variable name for a location in memory used to hold a data value assignment statement assigns a value to a variable = is the operator

p. 35 2.2 String Literals constant has same value throughout the program all caps final int TAX_RATE =.07; Summary - at bottom of p. 35 How is a constant different from a variable? (include how it must be declared) HW - p. 106 Self-Review 2.2, 2.4, 2.6 to 2.9 do on p. 34 in NB