Latest topics
» Young Boy nabbed for Raping 6-year-old girl in an Uncompleted building
Meaning Of this() in Java EmptyMon Jun 01, 2020 3:38 pm by Litifyed

» Mr Gbafun x Oladips – Ko Necessary
Meaning Of this() in Java EmptyWed May 27, 2020 9:25 am by Adminkunlex

» ZaddyMeek Ft. Mr Gbafun x Davolee – Nigga’s Doings
Meaning Of this() in Java EmptyWed May 27, 2020 9:23 am by Adminkunlex

» Full Css Code For Waphosts.com Website
Meaning Of this() in Java EmptyTue May 19, 2020 7:02 am by Adminkunlex

» Full Css Code For Waphosts.com Website
Meaning Of this() in Java EmptyTue May 19, 2020 7:01 am by Adminkunlex

» Chelsea star Callum Hudson-Odoi has been arrested
Meaning Of this() in Java EmptyMon May 18, 2020 8:52 pm by Litifyed

» MAKE $50 DAILY THROUGH DIGITAL TRADING
Meaning Of this() in Java EmptyMon May 18, 2020 11:39 am by skynett

» MTN 1.5gb for ₦300
Meaning Of this() in Java EmptyMon May 18, 2020 11:37 am by skynett

» Java Game: 4 Vengadores Hulk, Thor, Iron Man Capitn Amrica
Meaning Of this() in Java EmptyMon May 18, 2020 7:48 am by Adminkunlex

» Java Game: Heroes of World War II: Flying Tigers
Meaning Of this() in Java EmptyMon May 18, 2020 7:48 am by Adminkunlex

» Java Game: Call Of Duty: Modern Warfare: Force Recon
Meaning Of this() in Java EmptyMon May 18, 2020 7:47 am by Adminkunlex

» Are You Drinking Enough Water? 6 Signs You Need To Drink More Water
Meaning Of this() in Java EmptySun May 17, 2020 9:08 pm by Adminkunlex

» Advance Waphost File List Paging Code
Meaning Of this() in Java EmptySat May 16, 2020 6:46 pm by Adminkunlex

» How To Create CSS Theme In Waphosts.Com
Meaning Of this() in Java EmptyFri May 15, 2020 5:07 pm by Adminkunlex

» Samklef Ft. Victor AD – Give Thanks
Meaning Of this() in Java EmptyFri May 15, 2020 5:05 pm by Adminkunlex

» Peruzzi – Gaza (Prod. by Rexxie)
Meaning Of this() in Java EmptyFri May 15, 2020 4:59 pm by Adminkunlex

» Shizzi Ft. Davido & Wale – Won Le Ba
Meaning Of this() in Java EmptyFri May 15, 2020 7:39 am by Adminkunlex

» Davolee Ft. Masterkraft & Jaido P – G.O
Meaning Of this() in Java EmptyFri May 15, 2020 7:38 am by Adminkunlex

» DJ Val Exclusive Ft. Wande Coal x Dmain – Owonikoko
Meaning Of this() in Java EmptyFri May 15, 2020 7:37 am by Adminkunlex

» Rapsodii Ft. Obesere – 30 Milli
Meaning Of this() in Java EmptyFri May 15, 2020 7:35 am by Adminkunlex

The most tagged keywords



Meaning Of this() in Java

Go down

Meaning Of this() in Java Empty Meaning Of this() in Java

Post by Adminkunlex on Tue Mar 10, 2020 8:00 am

The keyword this in #Java refers to the current class instance i.e object. It can be used in multiple ways,
e.g
class Square{
Square(int height, int width)
{
this.height = height;
this.width = width;
}
}
Here this keyword makes sure the parameters
belongs to object and not parameters passed through
constructor Square().
Now what is
this():
this keyword here basically points to the constructor
of the class.
It can be used by one constructor to explicitly invoke
another constructor in the same class.
e.g
class Square
{
int height;
int width;
Square()
{
this(0,0);
}
Square(int side)
{
this(side, side);
}
Square(int height, int width)
{
this.height = height;
this.width = width;
}
}
So here, if we pass no arguments to constructor, 0 is
taken as both arguments and if only one argument is
passed then same value is used for both height and
width.

SOURCE

Adminkunlex
Admin

Posts : 1416
Join date : 2019-06-08
Age : 20
Location : Osun State, Nigeria

https://9jabaze.forumotion.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum