Answer the question
In order to leave comments, you need to log in
Why are public methods and variables not visible in the same package?
I work in IntelliJ Idea.
We have the Human class as a separate file.
public class Human {
public int age = 0;
public String name = "Nobody";
protected int height = 1;
protected int strength = 1;
public void setAge(int age) {
this.age = age;
}
public int getAge() {
return age;
}
public int getHeight() {
return height;
}
public int getStrength() {
return strength;
}
public class Life {
Human petrovich = new Human();
petrovich. // тут по ctrl+space мы узнаём, что нет доступа к методам и атрибутам Human
}
Answer the question
In order to leave comments, you need to log in
You didn't create a procedure in the Life class:
public class Life {
Human a = new Human();
public void test(){
a.getAge();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question