I've coded this program but i am getting this error,
EmployeeeMain.java:57: non-static method getdata() cannot be referenced from a s
tatic context
Manager.getdata();
^
1 error

I've used the same technique in other program , it is working fine but this program is not working !!
Why I am getting this error ??
should i set the method getdata() static ??

class Employee{
    private int code;
    private String name;
    
    protected String input(){
    int l=0;
    byte[] b=new byte[255];
    String S;
    try{
    l=System.in.read(b,0,255);
    }
    catch (Exception r){}
    S=new String (b,0,l-2);
    return S;
    }
    
    protected void get(){
    System.out.println ("Enter Employee name: ");
    name=input();
    System.out.println ("Enter Employee code: ");
    code=Integer.parseInt(input());
    }
    
    protected void show(){
    System.out.println("Employee Name: " + name);
    System.out.println("Code: " + code);
    }
}

class Manager extends Employee{  // Manager Profile
    private int salary;
    private String education,experience;
    
    protected void getdata(){
    super.get();
    System.out.println ("Enter Salary: ");
    salary=Integer.parseInt(super.input());
    System.out.println ("Enter Experience: ");
    experience=super.input();
    System.out.println ("Enter Education: ");
    education=super.input();
    }
    
    protected void showdata(){
    super.show();
    System.out.println("Salary: " + salary + " PKR");
    System.out.println("Education: " + education);
    System.out.println("Experience: " + experience );
    }
}


class EmployeeeMain{
public static void main(String args[]){
    Manager first = new Manager();
    System.out.println ("Manager's Data");
    Manager.getdata();
    }
}

getData is an instance method, so you call it via an instance of the Manager class (eg "first"). You have called it via the name of the class, not an instance. You can only do that for static methods.

This question has already been answered. Start a new discussion instead.