using spring dependency injection for runtime generated dependencies

I am new to Spring and to better understand what I’m learning, I decide to integrate Spring into one of my projects. In the project, a collection of Events is generated at runtime, where Event is a …

Is this considered a cyclic dependency (is this good practice)?

Hi I am a new Java programmer and have a small question about class design. I understand that something like this is a cyclic dependency and is probably not a way to structure a project: public class …

Checking Field boolean value in Java Composition Class

I’m having some trouble checking the boolean value for a composition class that holds a few boolean fields. If true a print line statement will print but I’m not sure if the boolean value is not …

Creating multiple objects using the same instance

I just saw this tutorial creating multiple objects using the same instance by applying the DAO pattern and tried it in a simple console, but I always get this message java.lang.NullPointerException I’…

How to create a new object of Public Class

I am a newbie in Java, although I have knowledge of Object Oriented Programming from Python but I’m currently having problem understanding this example on creating public class either combining the …

A method should be in the class which realises a action or in the realised class?

Maybe the title is a little confusing, but I didn’t know how to say it properly (my English is not good at all, so sorry if it is harder to understand). Let’s say we got 2 classes, Person and Group, …

Why is casting in equals necessary?

I’m doing the Mooc course and it’s teaching us how to compare objects from made up classes like “Person” and see if they are equal to each other. They give us the following code: public class …

Getting “cannot find symbol” error with reader.nextLine()

Here is my code (it is code to reverse a given string) import java.util.Scanner; public class ReversingName { public static String reverse(String text) { // write your code here int …

why the getter method goes null when i call in another class?

but in the set method on another class when i got the value is exist,, so i have 3 classes the first class is getter setter class , second is the class to fill the set and the last is class to get the …

Replacing if else statement with pattern

I have a if else statement which might grow in the near future. public void decide(String someCondition){ if(someCondition.equals(“conditionOne”)){ // someMethod(…