Let’s say this is somewhat like your Emp
class.
public class Emp {
private String name;
private int number;
private int salary;
public Emp( String name, int number, int salary ) {
this.name = name;
this.number = number;
this.salary = salary;
}
/* some methods */
}
Make another method called (for example) getSalary
like this
public int getSalary( ) {
return salary;
}
Then use it as follows
Emp e = new Emp("aBc", 12415, 02125);
System.out.println(e.getSalary()); // will print 2125 because that's the salary