Skip to content
Advertisement

Tag: arrays

Find all strings with smallest length in an array

I want to return the smallest values from my words array Finding the shortest word is easy but I am not sure how to return a new array with the shortest words. The expected output is something like shorestWords [] = {“is”, “is”} Answer Since most of the answers are not considering that result is expected in String[] instead of

java.lang.ArrayStoreException on List to Array

When I use the toArray function from Java util I get an ArrayStoreException with no message. I implemented the absolute same code a year ago in pretty much the same Model and it works there, the query works fine and returns [1,2] from the DB. here is the code I use: I dont understand why it would not show an

Java OOP; creating array of objects

I’d like to create an array of objects where 3 objects are from one class, and a 4th is from second class. In the first class I did the following: in the second class I did the following: In the main class, I created several pupil objects and one tutor object, like this: Using objects for printing in main works

Deserialising JSON array using RestTemplate

I’m trying to convert JSON data to a java class using Rest Template. The JSON data has this format and cannot be changed: The java class to save the data is: To receive the JSON data and deserialize i’m doing: But i’m getting this exception: I’ve done this before and it worked, but the JSON data had a slightly different

Save a Resultset to an Array in java

I want to save the result of a whole Mysql table in an array it returns this to me from the database run: brandon Brandon Julio Daniel BUILD SUCCESSFUL (total time: 1 second) I want to save what is in the database in an array to be able to implement it with a sort and search method that’s why I

Advertisement