Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Can';我想不出这个密码。请给出一些见解_Java_Methods - Fatal编程技术网

Java Can';我想不出这个密码。请给出一些见解

Java Can';我想不出这个密码。请给出一些见解,java,methods,Java,Methods,我不断收到错误方法外接程序类DebugThree2无法应用于给定类型,二进制运算符“-”的操作数类型错误 // This application displays some math facts public class DebugThree2 { public static void main(String args[]) { add(); subtract(); System.out.println("Java"); int a =

我不断收到错误
方法外接程序类DebugThree2无法应用于给定类型
二进制运算符“-”的操作数类型错误

// This application displays some math facts
public class DebugThree2 {

    public static void main(String args[]) {
      add();
      subtract();
      System.out.println("Java");
      int a = 2, b = 5, c = 10;
      add("a" + "b");
      add("b" + "c");
      subtract("c" - "a");            
    }

    public static void add() {
      System.out.println("The sum of " + "a" + "and" + "b" + "is" + "a" + "b");
    }

    public static void subtract() {
      System.out.println("The difference between " + "a" + "and" + "b" + "is" + "a" - "b");
    }
} 
我想这样的东西可能更适合你。您正试图从(字符串)a中减去(字符串)b


您必须使用它们的实际值,不包括引号

为什么将变量放在
”之间?为什么方法不接收任何参数?
public static void main(String args[])
{
  add();
  subtract();
  System.out.println("Java");
  int a = 2, b = 5, c = 10;
  add(a,b);
  add(b,c);
  subtract(c,a);            
}
public static void add(int a, int b)
{
  System.out.println("The sum of " + a +
     " and " +  b  + " is " + (a+b));
}
public static void subtract(int a, int b)
{
  System.out.println("The difference between " +
    a + " and  " + b + " is " + (a-b));
}
"a" - "b"