non-static method cannot be referenced from a static context.
I have the line of code in a class X:
{code}Database.addIngenieur(new Ingenieur(naam,voornaam,paswoord,ranking,email,tel efoon));{code}
In my Database class I have the method addIngenieur:
{code}public void addIngenieur(Ingenieur deIngenieur)
{
ingenieurs.add(deIngenieur);
}{code}
which should add the ingenieur to the arraylist ingenieurs.
My class Ingenieur looks like the following:
{code}
public class Ingenieur
{
private String naam;
private String voornaam;
private String ranking;
private String email;
private String telefoonnummer;
private String nota;
private String paswoord;
public Ingenieur(String deNaam, String deVoornaam, String hetPaswoord, String deRanking, String deEmail, String hetTelefoonnummer)
{
naam = deNaam;
voornaam = deVoornaam;
ranking = deRanking;
email = deEmail;
telefoonnummer = hetTelefoonnummer;
paswoord = hetPaswoord;
nota = "";
}
//Some other methods below...
}
{code}
But it gives me the following error in class X: non-static method addIngenieur(Ingenieur) cannot be referenced from a static context.
I just don´t see the error which should be obvious to a real programmer.
Can anyone help me?
Best Regards