我的代码编译得很好,但是当我运行它时,它给我一个错误:
`Static Error: This class does not have a static void main method accepting String[]`
这是我的密码:
class Employee{
private String name; //name reference field
private int idNumber; //integer variable holding employee's ID number
private String department; //holds the name of the employees department
private String position; //holds the name of the employee's position in the department
//the following is the first required constructor
//using the terms n,i,d, and p to assign values to the above fields
public Employee(String n, int i, String d, String p){
name=n;
idNumber=i;
department=d;
position=p;
}
//the following is a constructor that sets the fields blank to be filled in
public Employee(){
name="";
idNumber=0;
department="";
position="";
}
//writing appropriate accessor and mutator methods for all the fields
public void setName(String n){ name=n; }
public void setIdNumber(int i){ idNumber = i; }
public void setDepartment(String d){ department = d; }
public void setPosition(String p){ position = p; }
public String getName(){ return name; }
public int getIdNumber(){ return idNumber; }
public String getDepartment(){ return department; }
public String getPosition(){ return position; }
}
//new program creating employee objects
public class EmployeeInfo
{
public static void main(String[] args)
{
//create an Employee object
Employee employee1 = new Employee("Susan Meyers", 47899, "Accounting", "Vice President");
//test the accessor methods
System.out.println("***employee1***");
System.out.println("Name: " + employee1.getName());
System.out.println("ID number: " + employee1.getIdNumber());
System.out.println("Department: " + employee1.getDepartment());
System.out.println("Position: " + employee1.getPosition());
//create another Employee object
Employee employee2 = new Employee();
//test the mutator methods
employee2.setName("Mark Jones");
employee2.setIdNumber(39119);
employee2.setDepartment("IT");
employee2.setPosition("Programmer");
System.out.println("\n***employee2***");
System.out.println("Name: " + employee2.getName());
System.out.println("ID number: " + employee2.getIdNumber());
System.out.println("Department: " + employee2.getDepartment());
System.out.println("Position: " + employee2.getPosition());
//create another Employee object
Employee employee3 = new Employee();
//test the mutator methods
employee2.setName("Joy Rogers");
employee2.setIdNumber(81774);
employee2.setDepartment("Manufacturing");
employee2.setPosition("Engineer");
System.out.println("\n***employee3***");
System.out.println("Name: " + employee3.getName());
System.out.println("ID number: " + employee3.getIdNumber());
System.out.println("Department: " + employee3.getDepartment());
System.out.println("Position: " + employee3.getPosition());
}
}
我知道我需要在某个地方添加“publicstaticvoidmain(String[]args)”命令,但我不确定在哪里!谢谢你能给予的任何帮助!
您正在创建两个不同的类雇员和雇员信息我假设您正在尝试执行雇员类,其中编译器无法找到公共静态无效主
我在学习,我是新手,但我想知道我做什么来“运行”它。这是一个错误:
我得到了“静态错误:这个类没有接受字符串[]的静态void main方法”尽管我在使用Dr.Java的代码中有“public static void main(String args[]) 上面有代码,我没有错误,但当我试图运行代码时,我会得到错误。提前谢谢。 下面是对象类之外的代码 整个代码如下,我的文件保存为MergeSortnonRecursive.java
然而,当这个程序编译,但我得到的错误,这个类没有一个静态的无效主方法接受字符串[].我知道我应该在ZawTennisPlayer程序的某个地方添加一些公共静态无效主(字符串[]参数),但我不确定在哪里。知道如何修复程序以获得所需的输出吗??提前感谢! 我用来测试程序的示例代码“TestTennisplayer 2”是:
我正在尝试从下面的git链接运行代码 但我有个错误 nosuchMethodError:没有静态方法getFont(landroid/content/context;ilandroid/util/typedvalue;ilandroid/widget/textview;)landroid/graphics/typeface;在Landroid/Support/V4/Content/Res/Reso
我想知道这样的声明在Java是否有某种真正的意义。我在代码中发现了它几千次,但是我学习和玩字符串,我知道无论你声明一个对象多少次:如果你之前的某个类声明了这个字符串,它就会被汇集并重用(我说的是没有显式构造函数调用而创建的字符串) 事实上,这段代码在调用比较时打印,因此两个变量引用同一个对象。说变量无法重新定义,在这种情况下单词完全没有用。我是不是没抓住重点? 还有几件事: 1 - 为什么显式调用
我一直试图静态地将sfml链接到C++项目,但它总是给我带来编译器错误,有人知道这里发生了什么以及如何修复它吗; 编辑: 这是产生错误的代码: 严重性代码描述项目文件行抑制状态错误LNK2019未解析外部符号_JPEG_CreateCompress在函数“private:bool__thiscall SF::Priv::ImageLoader::WriteJPG(类STD::Basic_Strin