Lecture Java: Chapter 2

Lecture Java: Chapter 2 (Data and Expressions) presented Character Strings, Variables and Assignment, Primitive Data Types, Expressions, Data Conversion, Interactive Programs, Graphics, Applets, Drawing Shapes. | Copyright © 2012 Pearson Education, Inc. Chapter 2 Data and Expressions Java Software Solutions Foundations of Program Design Seventh Edition John Lewis William Loftus Data and Expressions Let's explore some other fundamental programming concepts Chapter 2 focuses on: character strings primitive data the declaration and use of variables expressions and operator precedence data conversions accepting input from the user Java applets introduction to graphics Copyright © 2012 Pearson Education, Inc. Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes Copyright © 2012 Pearson Education, Inc. Character Strings A string literal is represented by putting double quotes around the text Examples: "This is a string literal." "123 Main Street" "X" Every character string is an object in Java, defined by the String class Every string literal represents a String object Copyright © 2012 Pearson . | Copyright © 2012 Pearson Education, Inc. Chapter 2 Data and Expressions Java Software Solutions Foundations of Program Design Seventh Edition John Lewis William Loftus Data and Expressions Let's explore some other fundamental programming concepts Chapter 2 focuses on: character strings primitive data the declaration and use of variables expressions and operator precedence data conversions accepting input from the user Java applets introduction to graphics Copyright © 2012 Pearson Education, Inc. Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes Copyright © 2012 Pearson Education, Inc. Character Strings A string literal is represented by putting double quotes around the text Examples: "This is a string literal." "123 Main Street" "X" Every character string is an object in Java, defined by the String class Every string literal represents a String object Copyright © 2012 Pearson Education, Inc. The println Method In the Lincoln program from Chapter 1, we invoked the println method to print a character string The object represents a destination (the monitor screen) to which we can send output ("Whatever you are, be a good one."); object method name information provided to the method (parameters) Copyright © 2012 Pearson Education, Inc. The print Method The object provides another service as well The print method is similar to the println method, except that it does not advance to the next line Therefore anything printed after a print statement will appear on the same line See Copyright © 2012 Pearson Education, Inc. Copyright © 2012 Pearson Education, Inc. //******************************************************************** // Author: Lewis/Loftus // // Demonstrates the difference between print and println. //******************************************************************** public class .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.