Næste |
|
Grundlæggende javasyntaks serie, Planche nr. 22 |
![]() |
Kontrolstrukturer (2) |
Eksempel på while-struktur
import java.io.*; public class Count { public static void countChars(Reader in) throws IOException { int count = 0; while (in.read() != -1) count++; System.out.println("Counted " + count + " chars."); } // ... Hovedmetode udeladt ... }