Cannot Find Symbol

I have created a small Java application to automatically test some expressions for a true/false condition. I am getting two compiler errors in both jGRASP and with the javac command. The code follows: 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"); } } The error message is:
    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
What am I doing wrong? In the unlikely event that my instructor or any administrator from Salt Lake Community College ever comes across this question, let me make my intentions clear. This question is posted in the greatest spirit of academic honesty. I ask this question to seek general advice and help in understanding the proper way to use the Java programming language. I in no way use the work of others and represent it as my own work. I use the answers provided here as a general aid in my understanding. I do all my own work and do not copy work provided by people answering my question.
Generally speaking is always better to use brackets than not using them. Prefer if(){ ... } else { ... } over if() .. else ...

以上就是Cannot Find Symbol的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏