+ 1
[ANSWERED ]Access modifiers, return types
Pretty much all the errors I get come from defining modifiers, variable not found etc I want a very detailed tutorial or any other material on this topic. Any suggestions, please?
3 Answers
+ 1
Mate, you can visit this site for references,
https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html or https://www.javatpoint.com/access-modifiers
All the things about access modifiers are explained there. To get familiar, Try to create classes or sub-classes with different access modifiers, and try to access them, you should get the picture how they work or which on can be accessed or not. Cheers
0
@merkrafter
I just want a detailed tutorial with all the explanations on the processes.
I don't remember all the troubles I have faced. Not so recently I wondered what do we need return for when there's a static variable. And basically what do we need return at all. I've seen some guy's code, that returned a completely random thing, not even associated with what there was going on.
How to declare a method that returns 2 types of variables?
Why there's an error 'static not allowed here'
'illegal start of expression' in some places when trying to add some access modifiers.
Aaand so on.
- 1
What do you know so far? Maybe it's the best to help you that way as I could only repeat the lessons:
public... can be accessed from everywhere
<empty>... can only be accessed in the same package (or from everywhere if you don't use packages)
protected... can only be accessed in the same package or in subclasses
private... can only be accessed in the defining class