有阵列的麻烦,得到非法的表达开始

时间:2016-02-23 04:15:18

标签: java arrays sorting

你好我现在正在制作一个排序程序,但我试图创建这个方法来显示数组中的东西,它给我这个键。我真的不知道为什么这给了我这个错误和提示/帮助将不胜感激

public static void DisplayData(double payrate[], String names[])
    {
         for (int l=0; l<=payrate.length; l++) 
         {

           locationsum = 0;

           locationsum+=payrate[l];
           }

           for(int i=0;i<names.length;i++)
           {
              System.out.print(names[i]);

           System.out.printf("%6d\n", locationsum);

           } 

    }


project3.java:69: error: illegal start of expression
    public static void DisplayData(double payrate, String names)
    ^
project3.java:69: error: illegal start of expression
    public static void DisplayData(double payrate, String names)
           ^
project3.java:69: error: ';' expected
    public static void DisplayData(double payrate, String names)
                 ^
project3.java:69: error: '.class' expected
    public static void DisplayData(double payrate, String names)
                                          ^
project3.java:69: error: ';' expected
    public static void DisplayData(double payrate, String names)
                                                 ^
project3.java:69: error: ';' expected
    public static void DisplayData(double payrate, String names)
                                                               ^
6 errors

2 个答案:

答案 0 :(得分:0)

您忘了关闭} SortData()实施。在DisplayData()方法之前添加}

public static void SortData(double payrate[])
    {
        -----
    }//--> Missing closing here

答案 1 :(得分:0)

请验证您正确嵌套开放({)并关闭(})。你错过了Function

之上的任何一个
public static void DisplayData(double payrate[], String names[])

谢谢