为什么程序会给出“非法启动类型"?错误? [英] Why does the program give "illegal start of type" error?

查看:61
本文介绍了为什么程序会给出“非法启动类型"?错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是相关的代码片段:

public static Rand searchCount (int[] x) 
{
    int a ; 
    int b ; 
    int c ; 
    int d ; 
    int f ; 
    int g ;
    int h ; 
    int i ; 
    int j ;
    Rand countA = new Rand () ;
        for (int l= 0; l<x.length; l++) 
        {
            if (x[l] = 0) 
            a++ ;
            else if (x[l] = 1) 
            b++ ;
        }
    }
    return countA ;

}

(Rand 是这个方法所在的类名)

(Rand is the name of the class that this method is in)

编译时得到这个错误信息:

when compiling it get this error message:

Rand.java:77: illegal start of type
        return countA ;
        ^

这里出了什么问题?这个错误信息是什么意思?

what's going wrong here? what does this error message mean?

推荐答案

您在 return 语句之前放错了右大括号.

You have a misplaced closing brace before the return statement.

这篇关于为什么程序会给出“非法启动类型"?错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆