如何在函数调用中修复“找不到符号”?

时间:2017-03-27 13:34:58

标签: java overloading

我正在使用2种不同的数据类型实现方法重载。这就是我最终得到的代码。 但现在它找不到符号c和d。有什么帮助吗?

import java.util.*;
import java.lang.*;
public class LargestOfTwoTest{
    public static void main(String args[]) throws Exception{
        Scanner scan = new Scanner(System.in);



        System.out.println("Enter two numbers, and I wiil show you which one's largest!\n");
        System.out.println("Enter two numbers: ");
        double a = scan.nextDouble();
        double b = scan.nextDouble();

        if (a==(Math.floor(a))){
            int c = (int) a;
        }
        else{
            double c = a;
        }

        if (b==(Math.floor(b))){
            int d = (int) b;
        }
        else {
            double d = b;
        }

        System.out.print("Largest of the numbers is "+largest(c,d));
    }




    public static int largest(int x, int y){
        if (x>y)
            return x;
            //System.out.print("Largest of the numbers is "+x);
        else 
            return y;
            //System.out.print("Largest of the numbers is "+y);
    }
    public static double largest(double x, double y){
        if (x>y)
            return x;
            //System.out.print("Largest of the numbers is "+x);
        else 
            return y;
            //System.out.print("Largest of the numbers is "+y);
    }
}

显示此行中的错误

System.out.print("Largest of the numbers is "+largest(c,d));

...

LargestOfTwoTest.java:29:错误:找不到符号

(c和d)

1 个答案:

答案 0 :(得分:0)

vprop->orderedRGBA = 0xff0000ff; // By default applies to all vertices