Lecture Java: Chapter 5

Lecture Java: Chapter 5 focuses on boolean expressions, the if and if-else statements, comparing data, while loops, iterators, more drawing techniques, more GUI components. | Copyright © 2012 Pearson Education, Inc. Chapter 5 Conditionals and Loops Java Software Solutions Foundations of Program Design Seventh Edition John Lewis William Loftus Conditionals and Loops Now we will examine programming statements that allow us to: make decisions repeat processing steps in a loop Chapter 5 focuses on: boolean expressions the if and if-else statements comparing data while loops iterators more drawing techniques more GUI components Copyright © 2012 Pearson Education, Inc. Outline Boolean Expressions The if Statement Comparing Data The while Statement Iterators The ArrayList Class Determining Event Sources Check Boxes and Radio Buttons Copyright © 2012 Pearson Education, Inc. Flow of Control Unless specified otherwise, the order of statement execution through a method is linear: one after another Some programming statements allow us to make decisions and perform repetitions These decisions are based on boolean expressions (also called conditions) that evaluate to . | Copyright © 2012 Pearson Education, Inc. Chapter 5 Conditionals and Loops Java Software Solutions Foundations of Program Design Seventh Edition John Lewis William Loftus Conditionals and Loops Now we will examine programming statements that allow us to: make decisions repeat processing steps in a loop Chapter 5 focuses on: boolean expressions the if and if-else statements comparing data while loops iterators more drawing techniques more GUI components Copyright © 2012 Pearson Education, Inc. Outline Boolean Expressions The if Statement Comparing Data The while Statement Iterators The ArrayList Class Determining Event Sources Check Boxes and Radio Buttons Copyright © 2012 Pearson Education, Inc. Flow of Control Unless specified otherwise, the order of statement execution through a method is linear: one after another Some programming statements allow us to make decisions and perform repetitions These decisions are based on boolean expressions (also called conditions) that evaluate to true or false The order of statement execution is called the flow of control Copyright © 2012 Pearson Education, Inc. Conditional Statements A conditional statement lets us choose which statement will be executed next They are sometimes called selection statements Conditional statements give us the power to make basic decisions The Java conditional statements are the: if and if-else statement switch statement We'll explore the switch statement in Chapter 6 Copyright © 2012 Pearson Education, Inc. Boolean Expressions A condition often uses one of Java's equality operators or relational operators, which all return boolean results: == equal to != not equal to greater than = greater than or equal to Note the difference between the equality operator (==) and the assignment operator (=) Copyright © 2012 Pearson Education, Inc. Boolean Expressions An if statement with its boolean condition: if (sum > MAX) delta = sum – MAX; First, the condition is .

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.