< identifier>当试图调用一个类时 [英] <identifier> expected when trying to call a class

查看:97
本文介绍了< identifier>当试图调用一个类时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>

获得预期的错误标识符。我仍然在学习如何调用类,我相信我做错了。

I keep on getting the error identifier expected. I am still learning how to call classes and I believe I am doing it wrong.

推荐答案

问题是,有一个 OptionFrame 的构造函数 - 记住构造函数的格式是一个标识符,然后是类名,然后是括号中的任何参数(并且没有指定返回类型。示例可能是:

The issue is that you don't have a constructor for OptionFrame -- remember that the format of a constructor is an identifier, then the class name, then any arguments in parentheses (and no return type specified. So an example might be:

public OptionFrame() {
   ...
}

请记住,类中的语句总是分为三个类别 - 实例变量,构造函数和方法 - 对于任何不适合其中之一的错误语句,例如未包含在方法或构造函数中的打印语句。

Just remember that statements in classes are always grouped into three categories -- instance variables, constructors, and methods -- and watch out for any stray statements that don't fit into one of those, for example a print statement not embodied within a method or constructor.

这篇关于< identifier>当试图调用一个类时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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