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
Auf dieser Seite können Sie das Online-Video Introduction to Variables in Java | Java Tutorial For Beginners #9 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Sumit S Videos 06 Juni 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 84 Mal angesehen und es wurde von 7 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!