Skip to content

Tag: java

Using set and get methods in java

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…

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…

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…

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 &…