Ich habe eine kleine Java-Anwendung erstellt, um automatisch einige Ausdrücke auf eine Wahr/Falsch-Bedingung zu testen.Ich kann kein Symbol finden
Ich bekomme zwei Compiler-Fehler in beiden jGRASP und mit dem Befehl javac.
Der Code folgt:
public class MathTest {
public static void main(String[] args) {
int x = 10;
int y = 20;
int z = 30;
String string1 = "six";
String string2 = "six";
if (x < 10 || x > 10)
System.out.print("True");
else
System.out.print("False");
if (z - y == x && Math.abs(y - z) == z)
System.out.print("True");
else
System.out.print("False");
if (x < 10 && x < 10)
System.out.print("True");
else
System.out.print("False");
if (string1.equals(string2))
System.out.print("True");
else
System.out.print("False");
if (x > y || y > x)
System.out.print("True");
else
System.out.print("False");
if (!(x < y + z) || !(x + 10 <= 20))
System.out.print("True");
else
System.out.print("False");
if (string1 == string2)
System.out.print("True");
else
System.out.print("False");
}
}
Die Fehlermeldung lautet:
MathTest.java:14: cannot find symbol symbol : method abs(int) location: class Math if(z - y == x && Math.abs(y - z) == z) ^ ./Math.java:13: cannot find symbol symbol : method abs(int) location: class Math if(z - y == x && Math.abs(y - z) == z) ^ 2 errors
Was mache ich falsch?
In dem unwahrscheinlichen Fall, dass mein Lehrer oder irgendein Administrator vom Salt Lake Community College jemals auf diese Frage stößt, lassen Sie mich meine Absichten klarstellen. Diese Frage wird im größten Geist der akademischen Ehrlichkeit gepostet. Ich stelle diese Frage, um allgemeine Ratschläge und Hilfe beim Verständnis der richtigen Verwendung der Java-Programmiersprache zu erhalten. Ich benutze in keiner Weise die Arbeit anderer und stelle sie als meine eigene Arbeit dar. Ich verwende die hier gegebenen Antworten als allgemeine Hilfe für mein Verständnis. Ich mache all meine eigene Arbeit und kopiere nicht die Arbeit von Leuten, die meine Frage beantworten.
Generell ist es immer besser, Brackets zu benutzen als sie nicht zu benutzen.Bevorzugt if() {...} else {...} über if() .. else ... – OscarRyz