Local Variables -- Java Tutorial For Absolute Beginners
Local Variables -- Java Tutorial For Absolute Beginners
In Java, there are three types of variables
1. Local Variables
2. Instance Variables
3. Static or Class Variables
1) Local Variable
A local variable is a variable that is defined within a block, constructor or a method ( a Java method is a collection of statements that are grouped together to perform an operation).
The scope of a local variable remains limited to the particular block in which it is being declared and initialised.
Its lifetime is within the parenthesis in which it is declared.
Local Variable can be accessed outside of the method only through an object.
In Java, local variables are not given initial default values. The compiler checks to make sure that you have assigned a value before you use a local variable.
Unlike local variables, class variables and instance variables are given default values. Numeric types are automatically initialized to zero, and String variables are initialized to empty strings. As a result, you don’t have to initialize a class variable or an instance variable, although you can if you want them to have an initial value other than the default.
Please don't forget to subscribe !!!!!!
#codingriver
#javabasictutorial
#localvariablesinjava
Видео Local Variables -- Java Tutorial For Absolute Beginners автора Быстрый старт в программирование
Видео Local Variables -- Java Tutorial For Absolute Beginners автора Быстрый старт в программирование
Информация
4 декабря 2023 г. 19:53:27
00:19:01
Похожие видео