Hallo liebe Freunde, ich als blutiger JAVA-Einsteiger habe mal wieder ein Problem bei der Compilierung eines Beispieles aus einem Buch.
Es geht um die Verwendung von "PAIR", ich vermute mal stark, das dort am Anfang noch eine pasende import-anweisung fehlt, konnte aber im Internet nichts finden.
Hier ist der entsprechende Quell-Code:
public class PairTest {
public static void printEqual(Pair pair, String title) {
if (pair.areValuesEqual()) {
System.out.println("Gleiches Paar in " + title);
} else {
System.out.println("Ungleiches Paar in " + title);
}
}
public static void main(String[] args) {
Pair<Integer> pair1 = new Pair<>(4, 5);
PairTest.printEqual(pair1, "pair1");
Pair<String> pair2 = new Pair<>("Hallo", "Hallo");
PairTest.printEqual(pair2, "pair2");
}
}
Als Fehlermeldung bekomme ich folgende Ausgabe, wenn ich das mit javac PairTest.java compilieren will:
PairTest.java:2: error: cannot find symbol
public static void printEqual(Pair pair, String title) {
^
symbol: class Pair
location: class PairTest
PairTest.java:11: error: cannot find symbol
Pair<Integer> pair1 = new Pair<>(4, 5);
^
symbol: class Pair
location: class PairTest
PairTest.java:11: error: cannot find symbol
Pair<Integer> pair1 = new Pair<>(4, 5);
^
symbol: class Pair
location: class PairTest
PairTest.java:13: error: cannot find symbol
Pair<String> pair2 = new Pair<>("Hallo", "Hallo");
^
symbol: class Pair
location: class PairTest
PairTest.java:13: error: cannot find symbol
Pair<String> pair2 = new Pair<>("Hallo", "Hallo");
^
symbol: class Pair
location: class PairTest
5 errors
Ich bedanke mich für eure Hilfe im Voraus.
LG Creonic68
Es geht um die Verwendung von "PAIR", ich vermute mal stark, das dort am Anfang noch eine pasende import-anweisung fehlt, konnte aber im Internet nichts finden.
Hier ist der entsprechende Quell-Code:
public class PairTest {
public static void printEqual(Pair pair, String title) {
if (pair.areValuesEqual()) {
System.out.println("Gleiches Paar in " + title);
} else {
System.out.println("Ungleiches Paar in " + title);
}
}
public static void main(String[] args) {
Pair<Integer> pair1 = new Pair<>(4, 5);
PairTest.printEqual(pair1, "pair1");
Pair<String> pair2 = new Pair<>("Hallo", "Hallo");
PairTest.printEqual(pair2, "pair2");
}
}
Als Fehlermeldung bekomme ich folgende Ausgabe, wenn ich das mit javac PairTest.java compilieren will:
PairTest.java:2: error: cannot find symbol
public static void printEqual(Pair pair, String title) {
^
symbol: class Pair
location: class PairTest
PairTest.java:11: error: cannot find symbol
Pair<Integer> pair1 = new Pair<>(4, 5);
^
symbol: class Pair
location: class PairTest
PairTest.java:11: error: cannot find symbol
Pair<Integer> pair1 = new Pair<>(4, 5);
^
symbol: class Pair
location: class PairTest
PairTest.java:13: error: cannot find symbol
Pair<String> pair2 = new Pair<>("Hallo", "Hallo");
^
symbol: class Pair
location: class PairTest
PairTest.java:13: error: cannot find symbol
Pair<String> pair2 = new Pair<>("Hallo", "Hallo");
^
symbol: class Pair
location: class PairTest
5 errors
Ich bedanke mich für eure Hilfe im Voraus.
LG Creonic68