In my programming class, the teacher said we have to implement a class and use get methods but did not mention set methods in the description. Are they always used or should be used together? This is what I’ve written so far: Answer No, setters are not needed at all when implementing immutable classes/o…
Tag: java
How to get the next n fridays which are the first, second or third friday in a month?
I need to find the next n Fridays but want to exclude 4th and possibly 5th Fridays, i.e I want to get the next n Fridays which are 1st, 2nd or 3rd of each month. I have found a way to stream over the next n Fridays (example next 10 Fridays): Output: But I need to exclude for example 2021-10-22
Building a Recursive Data Structure with Spring WebFlux
I have a REST API that is built with the Spring WebFlux framework, and I have an endpoint which returns a Flux<ChannelResponse>, where ChannelResponse is a tree-structured object, as shown below: Now, I don’t have much experience with the reactive programming paradigm, but this is how I would impl…
needing help understanding this array method call [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question I just learned recently arrays. This exercise calls to return an average. I…
Set a transient object variable without serializing in Camunda
I have a process in Camunda that doesn’t have any user tasks. Iy has only some service tasks. I want to set a transient Object variable and then get in several tasks and manipulate it but Camunda forces me to make it implement the Serializable interface. My code is: but get the following exception: Is t…
How to access JSON field that doesn’t have identifier
How could I access the #19 that is at the end of this JSON? Im using java 11 with GSON library but any library is okay or explanation. Some context: usually I reference the field like .get(“id”) but that 19 is kind of the first time I see that and I know it is because of the circular reference tha…
How to remove “extras” from using java gradle shadow plugin
I’m using the gradle shadow plugin in my java project. I used the following code to get rid of all the dependencies I could. However, I’ve got all these extra files in my jar file. I want to remove everything except what’s in the “eu” folder and the “plugin.yml”. How …
A method that has a class return type
I don’t quite understand how am I going to implement and solve this problem: Consider an array data of n numerical values in sorted order and a list of numerical target values (target values are not necessarily sorted). Your goal is to compute the smallest range of array indices that contains all of the…
Are booleans implicitly true?
I’m a bit confused on this bit of code. My professor explained that the output will always be true but I’m confused on why. I changed the boolean to both true and false but the output is always true and I’m having a hard time explaining the logic behind it. I assumed that since a false &…
Why is my trapezoid rule implementation not producing expected results?
I have implemented a function to find the trapezoid rule of a given function, the function produces poor results for . When I try to calculate the trapezoid rule with n < 8 it produces a value much larger than the actual area, which is unexpected, I have graphed f(x) and drawn how I believe the first few n…