Рет қаралды 182,575
Check out our courses:
Java Full Stack and Spring AI - go.telusko.com...
Coupon: TELUSKO10 (10% Discount)
DevOps with AWS: From Basics to Mastery : go.telusko.com...
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : go.telusko.com...
Coupon: TELUSKO20 (20% Discount)
For More Queries about Course, WhatsApp or Call: +919008963671
website : www.telusko.com/
Instagram : / navinreddyofficial
Linkedin : / navinreddy20
TELUSKO Android App : bit.ly/TeluskoApp
TELUSKO IOS App : apple.co/3SsgmU2
Discord : / discord
In this lecture we will see:
Instance variable and Local variable
Can we declare two or more variables with the same name?
This keyword and its uses in Java
#1
Instance variable:- These variables are declared within a class but outside a method.
These variables are created when we create an object and are destroyed when the object is destroyed.
Local variable:- These variables are declared within a method but do not get any default value.
They are created when we enter a method or constructor and get destroyed when the call returns from the method.
#2
In Java, it is not allowed to declare two or more variables having the same name inside a scope either in class scope or method scope.
The preference is always given to the local variable.
Creating an object is not a good idea to solve the issue of conflicting names of instance and local variables.
We can differentiate between local and instance variables by passing an object itself.
Instead of writing and passing an object, we can simply use this keyword.
#3
This keyword:-
This keyword represents the current object.
Current object is an object which is calling the method.
This keyword is used to invoke the current class constructor.
Using the 'this' keyword, we can return the current class instance.
This keyword can be used as an argument in the constructor call.
Github repo : github.com/nav...
Java:- bit.ly/JavaUde...
Spring:- bit.ly/SpringU...
More Learning :
Java :- bit.ly/3x6rr0N
Python :- bit.ly/3GRc7JX
Django :- bit.ly/3MmoJK6
JavaScript :- bit.ly/3tiAlHo
Node JS :- bit.ly/3GT4liq
Rest Api :-bit.ly/3MjhZwt
Servlet :- bit.ly/3Q7eA7k
Spring Framework :- bit.ly/3xi7buh
Design Patterns in Java :- bit.ly/3MocXiq
Docker :- bit.ly/3xjWzLA
Blockchain Tutorial :- bit.ly/3NSbOkc
Corda Tutorial:- bit.ly/3thbUKa
Hyperledger Fabric :- bit.ly/38RZCRB
NoSQL Tutorial :- bit.ly/3aJpRuc
Mysql Tutorial :- bit.ly/3thpr4L
Data Structures using Java :- bit.ly/3MuJa7S
Git Tutorial :- bit.ly/3NXyCPu
Donation:
PayPal Id : navinreddy20
www.telusko.com