Рет қаралды 118,405
Check out our courses:
Enterprise Java Spring Microservices: go.telusko.com/enterpriseJava
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : bit.ly/java-spring-cloud
Coupon: TELUSKO20 (20% Discount)
Udemy Courses:
Java:- bit.ly/JavaUdemyTelusko
Spring:- bit.ly/SpringUdemyTelusko
Java For Programmers:- bit.ly/javaProgrammers
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusko.com/
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/navinreddy20/Javac...
Java:- bit.ly/JavaUdemyTelusko
Spring:- bit.ly/SpringUdemyTelusko
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