Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[ Zweidimensionales Array füllen ]

Empfohlene Antworten

Veröffentlicht

Hallo..

folgendes:

ich hab ein zweidimensionales Array das ich auf besondere weise füllen will..

der erste array wert soll eine Zahl von 1-10 sein..

und der zweite array wert soll eine gleiche menge unterschiedlicher worte werden..

in die erste []-Klammer schreib ich den index (1-10)

aber was soll ich in den 2ten schreiben??


myArray[1][?] {{},{"Wort1","Wort2","Wort3","Wort4","Wort5"}};
myArray[2][?] {{},{"Wort1","Wort2","Wort3","Wort4","Wort5"}};
usw..
[/PHP]

wie mach ich das.. möchte aber keine schleife verwenden!

Hallo,

Du must die beiden Array felder mit den Indexex ansprechen, wie Du schon gesagt hast.

Array 1 geht z. B. von 1 bis 5 und Array2 geht von 1 bis 3.


array[1][1] = "";
array[1][2] = ""
array[1][3] = ""
array[2][1] = ""
array[2][2] = ""
array[2][3] = ""
array[3][1] = ""
array[3][2] = ""
array[3][3] = ""
array[4][1] = ""
array[4][2] = ""
array[4][3] = ""
array[5][1] = ""
array[5][2] = ""
array[5][3] = ""
[/CODE]

Frank

Hallo mamamia!

Du meinst mit "ich will keine Schleifen benutzen" wahrscheinlich Initialisierungen mit literalen Arrays. Man kann ein Array ja entweder da deklarieren, dass man am Anfang einen bestimmten Speicher reserviert (int[] a = new int[5];) oder direkt den Speicher, also die Werte definiert, das wäre dann literal (int[] x = {1,2,3,4,5};)

Zu diesem Thema empfehle ich dir Kapitel "4.4 Arrays" aus Goto Java 2 www.javabuch.de . Dort wird auch die literale Deklaration von mehrdimensionalen Arrays ausgeführt:

public class Listing0410 

{

  public static void main(String[] args)

  {

    int[][] a = { {0},

                  {1,2},

                  {3,4,5},

                  {6,7,8,9}

                 };

    for (int i=0; i<a.length; ++i) {

      for (int j=0; j<a[i].length; ++j) {

        System.out.print(a[i][j]);

      }

      System.out.println();

    }

  }

}

Ciao,

Florian

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.