CSE 142 Lecture Notes - Lecture 4: Redundant Code

30 views3 pages
Verified Note
5 Oct 2018
School
Course

Document Summary

Therefore, when changing the value of y, the value of x does not change, y = 5; x. Redundant code public class mirror{ public static void main(string[] args){ drawline(); drawbody(); drawline(); public static void drawline(){ The for loop is a java statement that executes a disruption in the flow of control. The basic structure of the for loop is as follows, for (int i = 1; i <=4; i++){ More efficient mirror. java code public class mirror{ public static void main(string[] args){ drawline(); drawbody(); drawline(); public static void drawline(){ public static void drawbody(){ for (int i = 1; i <=8; i++){ However, we can make this even more efficient by putting a for loop inside a for loop, public class mirror3{ public static void main(string[] args){ drawline(); drawbody(); drawline(); public static void drawline(){ System. out. print(#); for (int k = 1; k <= 16; k++){ System. out. println(#); public static void drawbody(){ for (int i = 1; i <= 8; i++){

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents