1.Not only Bean, any java class without defined constructor will have a default no-argument constructor, but if you add any constructor with arguments, you need to explicitly define a no-argument constructor. can u illustrate
If we add any constructor with arguments it's not mandatory to define no-argument constructor. if we are creating other object with no-argument constructor then it will cause an issue. In that situation u need to mention no-argument constructor because compiler will not generate default constructor due to availability of parametrized constructor.
Mate, I finished this video with more questions than I had before starting it. You've managed to explain perfectly how to code a POJO and Java Bean. But you completely failed you explain WHY. E.g.: 1. Why can't the Java Bean constructor have parameters? 2. Why do the instance variablesn in a Java bean need to be private? 3. Why can't you directly access a Java Bean's variable directly? (i.e. Why do we HAVE to use the getter and setter methods?) And many more.
Thanks for the honest feedback. Wanted to keep video simple to the content. Also, I think most of the questions are self-explanatory. 1.Not only Bean, any java class without defined constructor will have a default no-argument constructor, but if you add any constructor with arguments, you need to explicitly define a no-argument constructor. 2.Reason was explained "Why implementing Serializable interface" at 4:03. To keep data secure the very purpose of 'private' access-modifier. 3.Again for the same reason as 2. You can't access as they are defined private. So, we have 'public' getters and setters to access the private instance variables. Hope this clarifies. But I take your point of WHY 👍
1.Not only Bean, any java class without defined constructor will have a default no-argument constructor, but if you add any constructor with arguments, you need to explicitly define a no-argument constructor.
can u illustrate
If we add any constructor with arguments it's not mandatory to define no-argument constructor. if we are creating other object with no-argument constructor then it will cause an issue. In that situation u need to mention no-argument constructor because compiler will not generate default constructor due to availability of parametrized constructor.
Starts from 7:40
Super useful explanation. Can I still have an arguments constructor in a Java Bean?
Yes. We can !!
but it is actually true that all beans are pojos since the pojos are not suposed to implement anything, right?
Correct. This is what has been mentioned at end of the video.
Superb explanation. Thank you.
Thank you !!
Mate,
I finished this video with more questions than I had before starting it.
You've managed to explain perfectly how to code a POJO and Java Bean. But you completely failed you explain WHY.
E.g.:
1. Why can't the Java Bean constructor have parameters?
2. Why do the instance variablesn in a Java bean need to be private?
3. Why can't you directly access a Java Bean's variable directly? (i.e. Why do we HAVE to use the getter and setter methods?)
And many more.
Thanks for the honest feedback.
Wanted to keep video simple to the content.
Also, I think most of the questions are self-explanatory.
1.Not only Bean, any java class without defined constructor will have a default no-argument constructor, but if you add any constructor with arguments, you need to explicitly define a no-argument constructor.
2.Reason was explained "Why implementing Serializable interface" at 4:03. To keep data secure the very purpose of 'private' access-modifier.
3.Again for the same reason as 2. You can't access as they are defined private. So, we have 'public' getters and setters to access the private instance variables.
Hope this clarifies.
But I take your point of WHY 👍
@@TechStack9 Thanks! That clarifies everything. Looking forward to more videos :)