mjstx
JCHJava Community | Help. Code. Learn.
•Created by mjstx on 1/2/2025 in #java-help
Java GUI not loading images/ImageIcons help
9 replies
JCHJava Community | Help. Code. Learn.
•Created by mjstx on 12/10/2024 in #java-help
java basics help
For this example:
I dont understand why we do this:
Animal dog = new Dog();
Animal cat = new Cat();
Why not just do something like, Dog dog = new Dog();, Cat cat = new Cat();
Also why CAN we do this and why doesnt it throw an error, because ive seen it happen that the left hand side of the initialization was sometimes an interface?
One thing that I found online was thit helps with abstraction, like for the method below. But why does it even make a difference at all, since Dog dog = new Dog(); is still an Animal so the method should it accept it too right?
public void handleSound (Animal animal) {
animal.makeSound();
}
39 replies
JCHJava Community | Help. Code. Learn.
•Created by mjstx on 6/5/2023 in #java-help
Creating a Java Unit test vectoraddition
17 replies
JCHJava Community | Help. Code. Learn.
•Created by mjstx on 6/4/2023 in #java-help
Junit test calling upon variable from a different class's method
19 replies
JCHJava Community | Help. Code. Learn.
•Created by mjstx on 6/4/2023 in #java-help
JUnit Test confusion
71 replies