Check full java topics on this main page
Java Modifiers
This is one of the important topics in java.
We will be using modifiers in every java program. Let us see what is modifiers
Modifiers are keywords that are used to specialize in class, variables, and methods. Specialize in the sense of providing a special ability for which the keyword got used.
Let us discuss in brief,
There are some important terms need to know before starting the concept
- Package - It is like a folder and it can contain many classes inside of it
- Class - This will contain a variable declaration, methods
- Methods - It is a small piece of script that can be used in the main method. Consider a calculator program. In that, we have many functions like adding subtraction rather than adding all our logic in the main method we can create methods in class and that can be called in the main method.
- Variable - This is used as a reference to store data
We will see the above terms in detail in our upcoming chapters.
The below diagram will show the basic form of the above-mentioned components
For simple understanding just think like the package is a house, the house having a lot of rooms and all rooms are used for some purposes like dining, cooking, etc.., In every room, there are some items to use. To use those items you need to open the door for that room.
Like the above scenario, the package is a house that having many classes(rooms). All classes(rooms) having a special purpose to do. In a class(room) we are having methods and variables(lamp in a room) and if you need to use that method(lamp) you need to go through the main method(room door).
Don't ask me a question what if the room does not have a main method. Even that case was allowed before java 7. Can use a static keyword instead of public static void main.
Modifiers are classified into two types
- Access modifiers - Provides access to class, variable, or method across packages and classes
- Non-Access modifiers - It does not provide access but it can provide some ability like hold the same reference location of a variable.
Let us discuss in detail every topic
Hope you are now clear on the above-mentioned concepts
Feel free to post your queries to us!!
Next Java Packages
Comments
Post a Comment