Đang chuẩn bị liên kết để tải về tài liệu:
Lecture Java methods: Object-oriented programming and data structures (3rd AP edition): Chapter 5 - Maria Litvin, Gary Litvin

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Chapter 5 - Java syntax and style. This is an important chapter because it explains and contrasts two related aspects of writing code in a high-level programming language: language syntax rules and good programming style. | Data Types, Variables, and Arithmetic int chapter = 5; Copyright © 2015 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 3rd AP edition 5- Java’s primitive data types and arithmetic operators can be hazardous due to integer division and arithmetic overflow. Take your time with this chapter until your students are comfortable with arithmetic. Objectives: Discuss primitive data types Learn how to declare fields and local variables Learn about arithmetic operators, compound assignment operators, and increment / decrement operators Discuss common mistakes in arithmetic 5- Also review the style: naming variables and using symbolic constants. Variables A variable is a “named container” that holds a value. q = 100 - q; means: 1. Read the current value of q 2. Subtract it from 100 3. Move the result back into q count 5 mov ax,q mov bx,100 sub bx,ax mov q,bx 5- The . | Data Types, Variables, and Arithmetic int chapter = 5; Copyright © 2015 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 3rd AP edition 5- Java’s primitive data types and arithmetic operators can be hazardous due to integer division and arithmetic overflow. Take your time with this chapter until your students are comfortable with arithmetic. Objectives: Discuss primitive data types Learn how to declare fields and local variables Learn about arithmetic operators, compound assignment operators, and increment / decrement operators Discuss common mistakes in arithmetic 5- Also review the style: naming variables and using symbolic constants. Variables A variable is a “named container” that holds a value. q = 100 - q; means: 1. Read the current value of q 2. Subtract it from 100 3. Move the result back into q count 5 mov ax,q mov bx,100 sub bx,ax mov q,bx 5- The code in the blue box is 8086 assembly language for IBM PC; ax and bx are general-purpose registers; mov is the move instruction; sub is the subtract instruction. Variables (cont’d) Variables can be of different data types: int, char, double, boolean, etc. Variables can hold objects; then the type is the class of the object. The programmer gives names to variables. Names of variables usually start with a lowercase letter. 5- More precisely, variables that represent objects hold references to (basically addresses of) objects. The space to hold the actual object is allocated elsewhere. Names of variables must be meaningful, not too long, not too short. If a name consists of several words, the subsequent words are capitalized (this is known as “camel-case”). A name cannot start with a digit. Variables (cont’d) A variable must be declared before it can be used: int count; double x, y; JButton go; Balloon b; String firstName; Type Name(s) 5- Several variables of the same type can be .

Đã 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.