Introduction to Variables in Java | Java Tutorial For Beginners #9
Variables in Java :
-----------------------------
Variables are used to store the values.
Variable is name of reserved area allocated in memory.
Ex: int roll = 40 ;
here, roll is a variable.
There are three types of variables in java :
------------------------------------------------------------------
1) Instance variable
2) Local variable
3) Static/Class variable
1) Instance variable: Variable declared inside the class but outside methods, constructor or block.
It will be created at the time of object creation.
Access modifiers can be used with instance variables.
Initialization is not mandatory. It has default value provided by JVM.
It will be stored in the Heap memory as the part of object.
2) Local variable : Local variable is declared inside a method, constructor or block.
It will be created while executing the method in which it is declared.
Initialization is mandatory. No default value for local variable.
Access modifiers cannot be used for local variables. Only final keyword can
be used.
Local variable are visible only within the method.
Local variable will be stored inside stack memory
3) Static variable : Variable declared with static keyword are called static variables.
Local variable can not be declared as static.
No need of object creation to call a static variable.
It will be created at the time of class loading.
Scope of static variable is same as the scope of class.
Calling of static variable :
---------------------------------------
Directly possible
By using class name possible
By using object reference name
Learn Core Java From Scratch
Don’t Forget To Like, Comment, Share & Subscribe !!
Keep Learning ! 😊
Important Playlist:
🆓 Software Installation For Developer : • Software Installation for Developer
🆓 JDBC Complete Tutorial : • JDBC Tutorial(Java Database Connectivity)
🆓 Core Java Tutorial : • Core Java Tutorials For Beginners
********************************| Thanks |****************************
#variables #corejava #sumitsvideos #sumitsingh
Related Searches :
local, instance and static variables in java
variables in java
types of variable in java
core java tutorial
In questa pagina del sito puoi guardare il video online Introduction to Variables in Java | Java Tutorial For Beginners #9 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Sumit S Videos 06 giugno 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 84 volte e gli è piaciuto 7 spettatori. Buona visione!