eclipse中为何无法运行源文件呢,,java
代码一个不错,在runas后面没有javaapplication选项,按altshiftx,j提示editordoesnotcontainamaintype,下面是源代码...
代码一个不错,在run as 后面没有java application 选项,
按alt shift x,j提示editor does not contain a main type,下面是源代码,就是运行不了,而有些就可以
package day12;
import java.util.Calendar;
import java.util.Comparator;
public class Employee implements Comparable<Employee>{
public static final Employee.EmployeeSalaryASC SALARYASC=new Employee.EmployeeSalaryASC();
public static final Employee.EmployeeBirthdayASC BIRTHDAYASC=new Employee.EmployeeBirthdayASC();
private String name;
private boolean genader;
private Calendar birthday;
private double salary;
public Employee(String name, boolean genader, Calendar birthday,
double salary) {
super();
this.name = name;
this.genader = genader;
this.birthday = birthday;
this.salary = salary;
}
public Employee() {
super();
}
public Calendar getBirthday() {
return birthday;
}
public void setBirthday(Calendar birthday) {
this.birthday = birthday;
}
public boolean isGenader() {
return genader;
}
public void setGenader(boolean genader) {
this.genader = genader;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
@Override
public boolean equals(Object obj) {
if(obj instanceof Employee){
Employee e=(Employee)obj;
if(this.name.equals(e.name) && getBirth(this.birthday).equals(getBirth(e.birthday))){
return true;
}
}
return false;
}
@Override
public int hashCode() {
return name.hashCode()^birthday.hashCode()^0x1a2b3c4d;
}
public void setSalary(double salary) {
this.salary = salary;
}
public static String getBirth(Calendar c){
int year=c.get(Calendar.YEAR);
int month=c.get(Calendar.MONTH);
int day=c.get(Calendar.DAY_OF_MONTH);
String birthday=year+"-"+month+"-"+day;
return birthday;
}
@Override
public String toString() {
return name+":"+getBirth(birthday)+":"+salary;
}
public int compareTo(Employee o) {
char thisfirst=this.name.charAt(0);
char ofirst=o.name.charAt(0);
if(thisfirst<ofirst){
return -1;
}else if(thisfirst>ofirst){
return 1;
}
return 0;
}
private static class EmployeeSalaryASC implements Comparator<Employee>{
public int compare(Employee e1, Employee e2) {
if(e1.salary<e2.salary){
return -1;
}else if(e1.salary>e2.salary){
return 1;
}
return 0;
}
}
private static class EmployeeBirthdayASC implements Comparator<Employee>{
public int compare(Employee e1, Employee e2) {
if(e1.birthday.getTime().getTime()<e2.birthday.getTime().getTime()){
return 1;
}else if(e1.birthday.getTime().getTime()>e2.birthday.getTime().getTime()){
return -1;
}
return 0;
}
}
} 展开
按alt shift x,j提示editor does not contain a main type,下面是源代码,就是运行不了,而有些就可以
package day12;
import java.util.Calendar;
import java.util.Comparator;
public class Employee implements Comparable<Employee>{
public static final Employee.EmployeeSalaryASC SALARYASC=new Employee.EmployeeSalaryASC();
public static final Employee.EmployeeBirthdayASC BIRTHDAYASC=new Employee.EmployeeBirthdayASC();
private String name;
private boolean genader;
private Calendar birthday;
private double salary;
public Employee(String name, boolean genader, Calendar birthday,
double salary) {
super();
this.name = name;
this.genader = genader;
this.birthday = birthday;
this.salary = salary;
}
public Employee() {
super();
}
public Calendar getBirthday() {
return birthday;
}
public void setBirthday(Calendar birthday) {
this.birthday = birthday;
}
public boolean isGenader() {
return genader;
}
public void setGenader(boolean genader) {
this.genader = genader;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
@Override
public boolean equals(Object obj) {
if(obj instanceof Employee){
Employee e=(Employee)obj;
if(this.name.equals(e.name) && getBirth(this.birthday).equals(getBirth(e.birthday))){
return true;
}
}
return false;
}
@Override
public int hashCode() {
return name.hashCode()^birthday.hashCode()^0x1a2b3c4d;
}
public void setSalary(double salary) {
this.salary = salary;
}
public static String getBirth(Calendar c){
int year=c.get(Calendar.YEAR);
int month=c.get(Calendar.MONTH);
int day=c.get(Calendar.DAY_OF_MONTH);
String birthday=year+"-"+month+"-"+day;
return birthday;
}
@Override
public String toString() {
return name+":"+getBirth(birthday)+":"+salary;
}
public int compareTo(Employee o) {
char thisfirst=this.name.charAt(0);
char ofirst=o.name.charAt(0);
if(thisfirst<ofirst){
return -1;
}else if(thisfirst>ofirst){
return 1;
}
return 0;
}
private static class EmployeeSalaryASC implements Comparator<Employee>{
public int compare(Employee e1, Employee e2) {
if(e1.salary<e2.salary){
return -1;
}else if(e1.salary>e2.salary){
return 1;
}
return 0;
}
}
private static class EmployeeBirthdayASC implements Comparator<Employee>{
public int compare(Employee e1, Employee e2) {
if(e1.birthday.getTime().getTime()<e2.birthday.getTime().getTime()){
return 1;
}else if(e1.birthday.getTime().getTime()>e2.birthday.getTime().getTime()){
return -1;
}
return 0;
}
}
} 展开
5个回答
展开全部
哥哥。。。。没有主函数。。。。。
再写一个public static void main(String[] args){
//你的代码,诸如new 啊什么的。。
}
再写一个public static void main(String[] args){
//你的代码,诸如new 啊什么的。。
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没有public static void main(String args[]) {
}方法
}方法
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
(⊙o⊙)哦God
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没有main方法的原因
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你没写
main
方法
main
方法
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询