GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ThinkJavaCode/ch07/Loops.java at master · lummypix/ThinkJavaCode Expand file tree/ Copy pathLoops.javaMore file actions 33 lines (28 loc) · 711 Bytes / Copy pathLoops.javaFile metadata and controls33 lines (28 loc) · 711 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 /** * Examples from Chapter 7. */ public class Loops { public static void countdown(int n) { while (n > 0) { System.out.println(n); n = n - 1; } System.out.println("Blastoff!"); } public static void sequence(int n) { while (n != 1) { System.out.println(n); if (n % 2 == 0) { // n is even n = n / 2; } else { // n is odd n = n * 3 + 1; } } } public static void main(String[] args) { System.out.println("countdown"); countdown(3); System.out.println("sequence"); sequence(10); } } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |