+ 1
Why I am not able to execute this program through passing parameters in main class
9 Réponses
+ 2
Each set method has to have void instead other declarations looks as follows:
public void setEmpId(int empId)
{
this.empId=empId;
}
It will be recommended that you make this java tutorial:
https://www.sololearn.com/learn/Java/2154/
+ 2
vinay kumar singh
Ur fix
use void in setter becoz they don't return any value
+ 1
So what shoul I do?
It still says that missing return statement in mutators
+ 1
Wherever you aren't returning change the function to public void
+ 1
// Created by vinay kumar singh
public class Employee
{
int empId;
String empName;
double salary;
public int getEmpId()
{
return empId;
}
public void setEmpId(int empId)
{
this.empId=empId;
}
public String getEmpName()
{
return empName;
}
public void setEmpName(String empName)
{
this.empName=empName;
}
public double getSalary()
{
return salary;
}
public void setSalary(double salary)
{
this.salary=salary;
}
public void display()
{
System.out.println("\nEmpId:"+getEmpId());
System.out.println("\nSalary:"+getSalary());
System.out.println("\nEmpName:"+getEmpName());
}
public static void main(String[] args) {
Employee e=new Employee();
e.setEmpId(100);
e.setEmpName("Vinay");
e.setSalary(1000.00);
e.display();
}
}
+ 1
Thanks alot guys
0
In your main...you've mixed up the get...() with your set....()....
and change your set....() methods to void.
0
Your code with changes:-
https://code.sololearn.com/c2eMbUg5ANck/#java
(compare)