java错误:'。类的期望值
嗨,朋友们,编译下面的错误就要来了
错误:'。课堂预期
我找不到错误是什么。我查看了很多网站,但找不到这个错误的原因。请帮忙
提前谢谢
import java.io.*;
class Test
{
boolean isGoodEmployee(boolean ismarried,int noofchild,String middlename,String childnames[])
{
boolean child,letter,last,child;
if (noofchild <= 2)
child=true;
boolean firstletter = middlename.startsWith("k");
boolean lastletter = middlename.endssWith("e");
if (firstletter && (!lastletter))
letter = true;
int lastnameletterscount = lastname.length();
if (lastnameletterscount > 4)
last = true;
String name = raju;
for (int i=0; i < noofchild; i++)
if(name.equalsIgnoreCase(childnames[i]))
{
child = true;
break;
}
}
}
class GoodEmployee
{
public static void main(String args[]) throws IOException
{
String firstname, middlename, lastname;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the first name of employee");
firstname = br.readLine();
System.out.println("enter the middle name of employee");
middlename = br.readLine();
System.out.println("enter the last name of employee");
lastname = br.readLine();
//System.out.println("full name of employee is:"+first+middle+last);
System.out.println("enter employee is married or not");
boolean ismarried = Boolean.parseBoolean(br.readLine());
if (ismarried)
System.out.println("enter number of childrens");
int noofchild = Integer.parseInt(br.readLine());
String childnames[] = new String[noofchild];
System.out.println("enter children names");
for (int i=0; i < noofchild; i++)
childnames[i] = br.readLine();
Test t = new Test();
t.isGoodEmployee(ismarried,noofchild,middlename,childnames[]);
}
}
我正在使用“javac GoodEmployee.java”来编译这个程序
# 1 楼答案
这个代码有很多错误:
在isGoodEmployee()(第1行)中,您已经声明了两次布尔子级
endssWith应该是endsWith()
等等,但这些都不是你所说的问题。你用什么命令行编译这个类
# 2 楼答案
如果您使用的是IDE,请将带有main方法的类公开。 如果您试图使用命令窗口运行它,我不认为有问题。类的文件是编译所必需的,而不是执行所必需的。所以在你有一个。通过输入javac GoodEmployee来初始化文件,如果没有错误,请输入java GoodEmployee,它将执行。你的班级档案