Skip to content
Advertisement

Tag: list

Java instantiated and initialized list (Explanation needed)

Could someone help me understand why the answer to this is (B)? Assume that animals has been instantiated and initialized with the following contents. [“bear”, “zebra”, “bass”, “cat”, “koala”, “baboon”] What will the contents of animals be as a result of calling manipulate ? Answer on first iteration, second iteration, third iteration, fourth iteration, fifth iteration, sixth iteration,

Get element value from a POJO List

I have the following POJO. And I create new indexes in the POJO my adding it. How can I have access to any index element once created? How I would be able to access the 3rd element from 3rd row? Answer First go to the 3rd element, then go the specific field that you want to access. in this case.

error: no suitable method found for newArrayList(String)

I am fairly new to Java and trying to use a Google Cloud service. When I am trying to use an explicit way to point my service account following this guide from this; https://cloud.google.com/docs/authentication/production#passing_code I already have installed requirements. However, this code throws an error as follows; I am not sure what is wrong in my setting and no luck

how to call class parameter inside the for loop?

Problem:Cannot call the class parameter inside the for loop statement Implementation:I need to call this class inorder my rest api list will function and will show all the data. Problem:Cannot call the class parameter inside the for loop statement Implementation:I need to call this class inorder my rest api list will function and will show all the data. Answer productEntity2

How to merge multiple Arrays containing the same value in Java

I’m struggling to find the best way to merge arrays (or create new ones) by looking at their shared value. this is my “dictionary” filled with arrays of 2 words, for example it contains arrays: I need to merge them by values they share, so for example the finished “dictionary” (or completely new list) would look like this: Also, the

Creating a list of avalible Timeslots based on a list LocalDateTime objects and a List of taken Timeslots with Streams

I have a List<Timeslot> that contains entity Timeslot with the following fields: timeslot_id; day; start_time; end_time. For example, this list contains two records: start_time of the first record equals 9:00 and end_time equals 10:00. start_time of second object equals 10:00 and end_time equals 11:00. And the second list contains timestamps List<LocalDateTime>: I need to create a third List<Timeslot> that will

How to put multiple values into a json in java

I’m trying to return a list of values from JDBC but multiple columns of the database to solve this I just made a JSON object to make something like this The issue is im getting this error WARN 43953 — [nio-1900-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation] What I’ve tried I’ve tried using a hash map but

Dynamic return type based on input argument type

I’m trying to write a small function that takes two lists and sorts one based on the elements of the other. So something like: would result in a sorted list [E, C, A, D, B]. However, valuesToSort might be a list of something different, like integers, floats or other lists. Ideally, I would want my program to take any list

Advertisement