Ich wollte zuerst ein Array initialisieren mit den Integern 1 bis 10 und anschließend mir mit einer For-Schleife die Werte anzeigen lassen. Das hat auch ganz gut geklappt:
int[]x = new int [] {1,2,3,4,5,6,7,8,9,10};
/* Create and initialise an array containing the integers
* 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 */
for (int i:x) {
System.out.println(i);
}
// Use a 'for' loop to print out the contens of the array
Als nächstes möchte ich mir mithilfe einer While-Schleife den Array-Inhalt in umgekehrter Reihenfolge anzeigen lassen, allerdings kommen immer wieder Fehlermeldungen, sowohl bei while (int i :x) als auch bei while (x<0), etc. so dass ich gar nicht weiter komme.
int[]x = new int [] {1,2,3,4,5,6,7,8,9,10};
/* Create and initialise an array containing the integers
* 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 */
for (int i:x) {
System.out.println(i);
}
// Use a 'for' loop to print out the contens of the array
Als nächstes möchte ich mir mithilfe einer While-Schleife den Array-Inhalt in umgekehrter Reihenfolge anzeigen lassen, allerdings kommen immer wieder Fehlermeldungen, sowohl bei while (int i :x) als auch bei while (x<0), etc. so dass ich gar nicht weiter komme.