CSE 142 Lecture Notes - Lecture 4: Redundant Code
CSE 142 verified notes
4/30View all
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++){