WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   Probleme mit equals (http://www.wcm.at/forum/showthread.php?t=60188)

Bizeps 19.06.2002 01:08

Probleme mit equals
 
public Hauptfenster(String Grp) {
initComponents();
jTextField1.setText(Grp);

String [][] Gruppen;
Gruppen = new String[1][3];
Gruppen[0][0]="Winf";
Gruppen[0][1]="Flo";
Gruppen[0][2]="Wolfgang";
Gruppen[0][3]="Markus";
Gruppen[1][0]="SCR";
Gruppen[1][1]="Herzog";
Gruppen[1][2]="Wallner";
Gruppen[1][3]="Konsel";

if (Grp.equals(Gruppen [0][0])) {System.out.println("ja");}
else {System.out.println("nein");
}
}

Bizeps 19.06.2002 01:09

Hab vorher noch vergessen mein Probelm zu posten.

Möchte auf Gleichheit testen aber irgendwie funkts nicht?

3of4 19.06.2002 03:08

probier es mal mit compareto, und beschreibe mal was dein Programm machen muss
hier ein kleiner Auszug von String-Vergleichsfunktionen.
Zitat:

int compareTo(Object o)
Compares this String to another Object.
________________________________________
int compareTo(String anotherString)
Compares two strings lexicographically.
________________________________________
int compareToIgnoreCase(String str)
Compares two strings lexicographically, ignoring case considerations.
________________________________________
boolean contentEquals(StringBuffer sb)
Returns true if and only if this String represents the same sequence of characters as the specified StringBuffer.
________________________________________
boolean equals(Object anObject)
Compares this string to the specified object.
________________________________________
boolean equalsIgnoreCase(String anotherString)
Compares this String to another String, ignoring case considerations.
Noch ein Tipp wie du dir das lange Array sparen kannst:
du kannst gleich schreiben:
String [][]Gruppen = { {"Winf","Flo","Wolfgang","Markus"},
{"SCR","Wallner","Herzog","Konzel"}
};

3of4 19.06.2002 03:23

Ps: wirft dir die vm keine ArrayIndexOutOfBoundsException bei deiner Arraydeklaration?
Du hast [1][3] angefordert, aber weil java mit [0][0] beginnt hast du in Wirklichkeit nur von [0][0] bis [0][2] zu Verfügung also meiner Ansicht nach ein Pseudomehrdimensionales Array.

Noch was, deine HP hat irgendwo einen Fehler drinnen, die UNI Wien meldet:

Dokument nicht gefunden !
Bitte überprüfen Sie den URL!

Bitte informieren Sie die Verantwortlichen der Seite http://www.wcm.at/vb2/showthread.php...94#post502194, daß der Link http://www.univie.ac.at/~a9804585/sonstiges.html falsch ist.

Bizeps 19.06.2002 11:39

re:letzter Beitrag
 
Du hast recht mit der Exception -- hab array falsch aufgebaut.
URL ist :www.unet.univie.ac.at/~a9804585

Tschau und Danke!

3of4 19.06.2002 12:06

bitte gerne geschehen, und wenn du noch fragen hast schreib.


Alle Zeitangaben in WEZ +2. Es ist jetzt 15:27 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag