/******************************************************************/ /* Prof. Dr. Carsten Vogt */ /* TH Koeln, Fakultaet IME */ /* http://www.nt.th-koeln.de/vogt */ /* */ /* Das Programm demonstriert grundlegende Operationen auf Arrays. */ /******************************************************************/ import java.io.*; public class Array { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); /* Deklaration von Arrayvariablen ohne oder mit Initialisierung */ short[] a; int[] b = new int[3]; double[] c = { 1.2, 2.3, 3.4, 4.5 }; /* Initialisierung der Arrayvariable a mit einem Array, der eine benutzergewaehlte Laenge hat */ System.out.println(); System.out.print("Gewuenschte Laenge von Array a: "); int lg = Integer.parseInt(in.readLine()); a = new short[lg]; /* Ausgabe der anfaenglichen Arrayinhalte unter Benutzung von for-Schleifen */ System.out.println(); System.out.println("Anfangswerte der Arrays:"); System.out.println(); System.out.print("a:"); for (int i=0; i