Issue
So I would like to use the variable "kierunek" from this class
public class Snake extends JPanel implements ActionListener{
char kierunek = 'D';
to this class
import pl.java.Snake.*;
public class MyKeyListener extends KeyAdapter {
importing shows "Unused import statement", I tried to find soulution, but there is nothing helping me
Solution
With Java you will have to either have to create a public Getter Method, or make the variable itself public.
As a object oriented Language Java differentiates between different access modifiers. More on that here: What is the difference between public, protected, package-private and private in Java?
Usually one should use Getter and Setter as accessors for the variables in order to avoid creating Problems.
More on why here: Why use getters and setters/accessors?
Answered By - Daniellllll Answer Checked By - David Marino (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.