Skip to content
Sign upLog in
Profile icon

Shade

@ShadeVI
Repls
Community
ShadeVI
ShadeVI
shared a Post
2 years ago
1
Feedback and Question
Hello guys, I was making this exercise. Works well but i have a question. Is there a way to run printInfo() of the Employee object only if HumanResou
Inheritance, super, overriding, composition
Java
Coder100
Coder100
Well yes, just remove the printInfo in Employee.java. Now, Employees won't be able to run the method, but HumanResources can.2 years ago
RYANTADIPARTHI
RYANTADIPARTHI
i think so. Whatever utils you have gotten, you take that name and say .info('something'). like that. maybe that will work.2 years ago
ShadeVI
ShadeVI
shared a Post
2 years ago
1
Hi guys, i'm new to Java, so i'm trying to understand a lot of stuff i've never heard before. Please can you give me some feedback about this code? I
10 - Composition
Java
ShadeVI
ShadeVI
@SUHASTADIPARTH1 @RYANTADIPARTHI Did you mean something like this?2 years ago
SUHASTADIPARTH1
SUHASTADIPARTH1
Looks awesome. Might want to try using more functions and classes instead of piling all the code in the main class....2 years ago
RYANTADIPARTHI
RYANTADIPARTHI
looks pretty good. One thing though. Might not want to use so many prints for separating. Try this instead - \n2 years ago
ShadeVI
ShadeVI
shared a Post
2 years ago
2
Hi guys, is there any difference between these two ways? List wordlist = new ArrayList (); and ArrayList wordlist = new ArrayList ();
hellooneplus
hellooneplus
The main differences between List and ArrayList are given below List is an interface while ArrayList is a class. List wordlist = new ArrayList (); In the above line, we are assigning the ArrayList class object to the List interface. There is a big plus on declaring them using the interface, which is what is known as "coding to an interface" instead of "coding to an implementation" which is a big Object-Oriented Design (OOD) principle. 1) Declaring them using an interface, means you can later1 year ago
Coder100
Coder100
Difference List is abstract, so you can change it's 'type'. ArrayList is not, but it will allow you more speed if you know all your types are going to be the same. Which one to use? I have always used ArrayList, and have never found any need for List. https://java2blog.com/java-list-vs-arraylist/2 years ago
RYANTADIPARTHI
RYANTADIPARTHI
Solution the list in java is not dynamic, Meaning it can hold only a certain amount on information, based on what you put. So whatever value you want it to hold, that's all it can. While the array list is a dynamic. You don't have to specify anything. You can add how much you want. the internal process just makes more, and more space foryou to add unlimited.2 years ago
ShadeVI
ShadeVI
shared a Post
2 years ago
1
Hello guys, can you help me to understand this? I have this example and in the second constructor Account the settler setBalance uses this.balance bu
Constructors & Overloading
Java
Coder100
Coder100
this.balance is the one scoped to your class, but it can also be balance. Because in the second constructor balance is already an argument, you can no longer use balance to reference the property inside your class. Did that make sense?2 years ago