此代码中的错误在哪里?用于netbeans ide 8.2 rc的java

qgzx9mmu  于 2021-06-30  发布在  Java
关注(0)|答案(3)|浏览(346)

这个问题在这里已经有答案了

printstream类型中的println(int)方法不适用于参数(string,int,int,int)(6个答案)
上个月关门了。
\问题出在哪里

public static void displaySum(int x , int y) {
    System.out.println("Sum of %d and %d is %d ",x,y,x+y);   
}

/* -----*/

public static int dispalySum(int x , int y ){
    System.out.println("First number is %.2f \n" + x );
    System.out.println("Second number is %.2f \n" + y );
    System.out.println("Sum is %.2f \n" + x+y );
    return x+y;
}

/

xytpbqjk

xytpbqjk1#

这个 System.out.println() 方法不支持格式化。请尝试以下操作:

public static void displaySum(int x , int y) 
{
    System.out.printf("Sum of %d and %d is %d ",x,y,x+y);   
}

或者:

public static void displaySum(int x , int y) 
{
    System.out.format("Sum of %d and %d is %d ",x,y,x+y);   
}
kuuvgm7e

kuuvgm7e2#

----/

public static void main(String[] args){
    int num1 = 3;
    int num2 = 2;
    displaySum(num1,num2);
}

}

导入java.util.scanner;
公共类测试{

public static void main(String[] args) {

//我能在这里做什么?

UcakRezervasyonSistemi thyRezervasyonSistemi = new UcakRezervasyonSistemi(5);

/????????/

Scanner input = new Scanner(System.in);

    String inputKey = "c";

    while(inputKey.equals("c" )|| inputKey.equals("C")){
        thyRezervasyonSistemi.rezervasyonAl();
        System.out.println("\nDevam etmek için c'ye, çıkmak için herhangi başka bir tuşa basınız ");
        inputKey = input.next();
    }

}

}

vs3odd8k

vs3odd8k3#

您可能使用错误的方法来编写int数据类型函数。用途:打印(displaysum(num1,num2));

相关问题