Sir enum create pannitu, 5 constants define panniten , then default constructor create pannitu adhukula syso("Test") nu potta, it displays Test as 5 times when I just call 1 cnstats with its enum class. public class HandleLocators { enum Locator{
int a; Locator(int a){ System.out.println("parameter Constructor"); this.a=a; }
Locator(){ System.out.println("Default Constructor"); } } public static void main(String[] args) { // TODO Auto-generated method stub HandleLocators obj1 = new HandleLocators();
obj1.clickElement("", Locator.LINKTEXT); }
public void clickElement(String elementValue, Locator locatorType){ switch(locatorType){ case ID: System.out.println("This is ID"); break; case NAME: System.out.println("This is NAME"); break; case CLASSNAME: System.out.println("This is CLASSNAME"); break; case LINKTEXT: System.out.println("This is LINKTEXT"); break; case PARTIALLINKTEXT: System.out.println("This is PARTIALLINKTEXT"); break; case TAGNAME: System.out.println("This is TAGNAME"); break; case CSSSELECTOR: System.out.println("This is CSSSELECTOR"); break; case XPATH: System.out.println("This is XPATH"); break;
} } } Output: Default Constructor Default Constructor Default Constructor parameter Constructor Default Constructor Default Constructor Default Constructor Default Constructor This is LINKTEXT How am I getting this output? Why its calling the constructor 8 times when I called the enum constants only once. Please give me your reply.. I understand it but I am confused due to this behaviour.
To my understanding, your 'enum' constructor is called 8 times (7 times default and 1 time parameterized) because, u have 8 enum objects (ID,NAME,CLASSNAME,LINKTEXT(4),PARTIALLINKTEXT,CSSSELECTOR,TAGNAME,XPATH). The first time you call for an enum object ,here in your case this line ---> [ obj1.clickElement("",Locator.LINKTEXT) ], all objects gets initialized/assigned. (Here your are accessing the LINKTEXT object from the enum Locator). To try this, try to access a second enum object and see, you will not get the constructor messages again. Also, you did not provide a default constructor for 'HandleLocators' class, hence while creating the object obj1 in this line --> [ HandleLocators obj1 = new HandleLocators(); ], the compiler will provide one.
Excellent explanation, with clear understanding 👍🏼
Sir angular beginners ku oru vedio podunga sir unga vedio matum tha comfortable ah iruku
Really unga explanation rombha cleara iruku purira maari solli taringu enaku nijamave unga video pudichidichi inniki madhiyano enaku java internals undo so naa adhukaga unga video paathu prepare aagre. Enaku college le solli kudukradhu vida unga teachinge nalla puriyudhu. College le sari solli kudukadhuku namaku exam day vandhu padikka kashtamaavu topicsa evlo padichalu thale kulle pogadhu apro ara gura padichi manapaadam panni examle ennamo ennamo eludhuvo marks rombha kammi varudhu Sela sandarbathule failu kooda aavo exam le pass aagununa marksa nallame vaangununa first unga video paakunu unmaile neenge rombha cleara ellaruku puriya veikkringu indha enum topica java le innu nereya nalla nalla topics kedecha adhuvu upload panntu poitye irungu. Enaku class le solli kudukradhu onnume puriyadhu rombha tharamaana explanation unguludhu unga video enaku topicsa understand pannikradhuku rombha helpful aaitruku. Enaku unga video paatha apro enum concept vandhu 95-99% purinjuchu examle namaku terinjirkradha eladhala ennmo confidence vandha maari kidhu unga teaching purinjikka rombha sulabham nge
Thank you for your kind words !!! Enjoy your learning !!!
@@PayilagamChennai sir enaku unga teaching rombha pudichidichi sir adhunaala naa ivlo persaana comment potruke nethu java internals rombha easyaagirundadu neenge solli kuduthade vandhirundadu rombha arama exam eludhe nethu appdi cloud computing subject enaku rombha kashtamaaitruku adhoda topics yedhaachu irundha upload pannungu nethu namaku rend rendu exams irundadu morning vandhu cloud computing madhiyano vandhu advanced java. Kaalaile enaku cloud computing exam eludhra po rombha kashtamaachi fail aaga vendiya chances kidhu adhule naanu please neenge cloud computing subjectku sambandamaana topicsa post pannidungu nethu naa cloud computing subject edhum bodhu rombha sirma patte
Please check below video for Cloud Computing
ua-cam.com/video/rTAwsa-g6kg/v-deo.htmlsi=o1b8LKWUi9K9c8xW
@@PayilagamChennai rombha thanks sir cloud computing videova share pannadhuku unga video paathaadu enaku cloud computing subject mulsa cleara puriyudhunu nenekkre sir.
Sir java Singleton and volatile Explain video podunga
Very good explanation sir 🥰😍
Sir some hide la irukku antha video access venum
Thank you so much sir
Sir stream topic podunga sir
Thank you sir
Rombha thankss sir 👍🏼 👍🏼👍🏼👍🏼
Well explained
Advanced java videos upload pannunga!!!!
Super sir
Super
Nested class and inner class both of same ah sir
Yes
ENUM acts like json objects
Sollunga singaram😂
Sir enum create pannitu, 5 constants define panniten , then default constructor create pannitu adhukula syso("Test") nu potta, it displays Test as 5 times when I just call 1 cnstats with its enum class.
public class HandleLocators {
enum Locator{
ID, NAME, CLASSNAME, LINKTEXT(4), PARTIALLINKTEXT, TAGNAME, CSSSELECTOR, XPATH;
int a;
Locator(int a){
System.out.println("parameter Constructor");
this.a=a;
}
Locator(){
System.out.println("Default Constructor");
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
HandleLocators obj1 = new HandleLocators();
obj1.clickElement("", Locator.LINKTEXT);
}
public void clickElement(String elementValue, Locator locatorType){
switch(locatorType){
case ID:
System.out.println("This is ID");
break;
case NAME:
System.out.println("This is NAME");
break;
case CLASSNAME:
System.out.println("This is CLASSNAME");
break;
case LINKTEXT:
System.out.println("This is LINKTEXT");
break;
case PARTIALLINKTEXT:
System.out.println("This is PARTIALLINKTEXT");
break;
case TAGNAME:
System.out.println("This is TAGNAME");
break;
case CSSSELECTOR:
System.out.println("This is CSSSELECTOR");
break;
case XPATH:
System.out.println("This is XPATH");
break;
}
}
}
Output:
Default Constructor
Default Constructor
Default Constructor
parameter Constructor
Default Constructor
Default Constructor
Default Constructor
Default Constructor
This is LINKTEXT
How am I getting this output? Why its calling the constructor 8 times when I called the enum constants only once.
Please give me your reply.. I understand it but I am confused due to this behaviour.
To my understanding, your 'enum' constructor is called 8 times (7 times default and 1 time parameterized) because, u have 8 enum objects (ID,NAME,CLASSNAME,LINKTEXT(4),PARTIALLINKTEXT,CSSSELECTOR,TAGNAME,XPATH).
The first time you call for an enum object ,here in your case this line ---> [ obj1.clickElement("",Locator.LINKTEXT) ], all objects gets initialized/assigned. (Here your are accessing the LINKTEXT object from the enum Locator).
To try this, try to access a second enum object and see, you will not get the constructor messages again.
Also, you did not provide a default constructor for 'HandleLocators' class, hence while creating the object obj1 in this line --> [ HandleLocators obj1 = new HandleLocators(); ], the compiler will provide one.