package Test;
class Yuan{
private int empno;
private String ename;
private String job;
private double sal;
private double comm;
public Yuan(){};
public Yuan(int eno,String ena,String j,double s,double c){
empno=eno;
ename=ena;
job=j;
sal=s;
comm=c;
}
public void setEmpno(int eno){
empno=eno;
}
public void setEname(String ena){
ename=ena;
}
public void setJob(String j){
job=j;
}
public void setSal(double s){
sal=s;
}
public void segComm(double c){
comm=c;
}
public int getEmpno(){
return empno;
}
public String getEname(){
return ename;
}
public String getJob(){
return job;
}
public double getSal(){
return sal;
}
public double getComm(){
return comm;
}
public String getInfo(){
return "雇员编号:"+empno+"\n"+
"雇员姓名:"+ename+"\n"+
"雇员职位:"+job+"\n"+
"基本工资:"+sal+"\n"+
"雇员奖金:"+comm;
}
public class OneOne{
public static void main(String[] args) {
// TODO Auto-generated method stub
Yuan Y=new Yuan(777,"sun","ceo",800.00,100.00);
System.out.println(Y.getInfo());
}
}
}
请大神看一下我这个JAVA里面哪里有问题啊,为什么 public static void main(String[] args) 报错
答案:1 悬赏:40 手机版
解决时间 2021-02-16 10:14
- 提问者网友:心如荒岛囚我终老
- 2021-02-15 18:36
最佳答案
- 五星知识达人网友:夜风逐马
- 2021-02-15 19:56
//将class OneOne 放到Yuan外面就行了
class Yuan{
private int empno;
private String ename;
private String job;
private double sal;
private double comm;
public Yuan(){};
public Yuan(int eno,String ena,String j,double s,double c){
empno=eno;
ename=ena;
job=j;
sal=s;
comm=c;
}
public void setEmpno(int eno){
empno=eno;
}
public void setEname(String ena){
ename=ena;
}
public void setJob(String j){
job=j;
}
public void setSal(double s){
sal=s;
}
public void segComm(double c){
comm=c;
}
public int getEmpno(){
return empno;
}
public String getEname(){
return ename;
}
public String getJob(){
return job;
}
public double getSal(){
return sal;
}
public double getComm(){
return comm;
}
public String getInfo(){
return "雇员编号:"+empno+"\n"+
"雇员姓名:"+ename+"\n"+
"雇员职位:"+job+"\n"+
"基本工资:"+sal+"\n"+
"雇员奖金:"+comm;
}
}
public class OneOne{
public static void main(String[] args) {
Yuan Y=new Yuan(777,"sun","ceo",800.00,100.00);
System.out.println(Y.getInfo());
}
}
class Yuan{
private int empno;
private String ename;
private String job;
private double sal;
private double comm;
public Yuan(){};
public Yuan(int eno,String ena,String j,double s,double c){
empno=eno;
ename=ena;
job=j;
sal=s;
comm=c;
}
public void setEmpno(int eno){
empno=eno;
}
public void setEname(String ena){
ename=ena;
}
public void setJob(String j){
job=j;
}
public void setSal(double s){
sal=s;
}
public void segComm(double c){
comm=c;
}
public int getEmpno(){
return empno;
}
public String getEname(){
return ename;
}
public String getJob(){
return job;
}
public double getSal(){
return sal;
}
public double getComm(){
return comm;
}
public String getInfo(){
return "雇员编号:"+empno+"\n"+
"雇员姓名:"+ename+"\n"+
"雇员职位:"+job+"\n"+
"基本工资:"+sal+"\n"+
"雇员奖金:"+comm;
}
}
public class OneOne{
public static void main(String[] args) {
Yuan Y=new Yuan(777,"sun","ceo",800.00,100.00);
System.out.println(Y.getInfo());
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯