I got the follow errors:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
groeße cannot be resolved or is not a field
geschlaecht cannot be resolved or is not a field
groeße cannot be resolved or is not a field
public static void main(String[] args) {
person Emil = new person();
Emil.name = "Emil";
Emil.alter = 22;
Emil.groeße = 18;
Emil.geschlaecht = "maennlich";
System.out.println("Emil: " + Emil + "Alter" + Emil.alter + "Name:" + Emil.name + "Größe" + Emil.groeße);
}
public class person{
public String name;
public byte alter;
}
public class Eigenschaften extends person {
public byte groeße;
public String geschlaecht;
}
I tried to fix it as per other users' comments. Now emil
is an Eigenschaften
New error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
No enclosing instance of type QuizFrage is accessible. Must qualify the allocation with an enclosing instance of type QuizFrage (e.g. x.new A() where x is an instance of QuizFrage).
at QuizFrage.main(QuizFrage.java:5)
public class QuizFrage {
public static void main(String[] args) {
Eigenschaften emil = new Eigenschaften();
emil.name = "Emil";
emil.alter = 22;
emil.groeße = 18;
emil.geschlaecht = "maennlich";
System.out.println("Emil: " + emil + " Alter" + emil.alter + " Name:" + emil.name + " Größe" + emil.groeße);
}
class Person{
public String name;
public byte alter;
}
class Eigenschaften extends Person {
public byte groeße;
public String geschlaecht;
}
}