package com.ckstudy;
import java.util.Scanner;
public class fangfa2 {
public static void main(String[] args) {
System.out.println("please enter firstnumber");
Scanner sc = new Scanner(System.in);
double firstnumber = sc.nextDouble();
System.out.println("please enter secondnumber");
double secondnumber =sc.nextDouble();
getmax(firstnumber,secondnumber);
}
public static void getmax(double a,double b){
if(a>b){
System.out.println("max=",a);
}
if(aSystem.out.println("max=",b);
}
else;
System.out.println("error");
}
}
java: 对于println(java.lang.String,double), 找不到合适的方法
方法 java.io.PrintStream.println()不适用
(实际参数列表和形式参数列表长度不同)
方法 java.io.PrintStream.println(boolean)不适用
(实际参数列表和形式参数列表长度不同)
方法 java.io.PrintStream.println(char)不适用
(实际参数列表和形式参数列表长度不同)
方法 java.io.PrintStream.println(int)不适用
(实际参数列表和形式参数列表长度不同)
方法 java.io.PrintStream.println(long)不适用
(实际参数列表和形式参数列表长度不同)
方法 java.io.PrintStream.println(float)不适用
(实际参数列表和形式参数列表长度不同)
方法 java.io.PrintStream.println(double)不适用
(实际参数列表和形式参数列表长度不同)
方法 java.io.PrintStream.println(char[])不适用
(实际参数列表和形式参数列表长度不同)
方法 java.io.PrintStream.println(java.lang.String)不适用
(实际参数列表和形式参数列表长度不同)
方法 java.io.PrintStream.println(java.lang.Object)不适用
(实际参数列表和形式参数列表长度不同)
else; 去掉分号
public static void getmax(double a,double b){
if(a>b){
System.out.println("max=" + a);
}
else if(a<b){
System.out.println("max=" + b);
}
else
System.out.println("error");
你这个错误挺多的,不止一处,正确的代码,我帮你修改好了,还请采纳:
import java.util.Scanner;
public class fangfa2 {
public static void main(String[] args) {
System.out.println("please enter firstnumber");
Scanner sc = new Scanner(System.in);
double firstnumber = sc.nextDouble();
System.out.println("please enter secondnumber");
double secondnumber = sc.nextDouble();
getmax(firstnumber, secondnumber);
}
public static void getmax(double a, double b) {
if (a > b) {
System.out.println("max=" + "," + a);
}
if (a < b) {
System.out.println("max=" + "," + b);
} else {
System.out.println("error");
}
}
}
打印的内容里面 ; 改成 + 就可以了