Skip to content

Tag: arrays

Separate “for” loop iterations

How would I go about making each iteration of my four loop be random. The outcome as of now makes all 20 sentences put the same output, although it is choosing random words each time from the four arrays created in static class OuterWord. I have omitted the parts of the code that I don’t think are neces…

Share an array between threads in java

I’m currently working on my own little boardgame and came across a problem with multithreading. I have one thread that renders the board and one that supplies the data to render. The supply thread writes his data to one array and then the renderer takes this data and renders it on the screen (The render…

Finding the longest word ArrayList /Java

I want to write a method which finds the longest String (word). The output should be the longest word in case of two words with the same lenght the output should be: “More than one longest word”. I used ArrayList and almost had a solution, but something goes wrong. The case is that I have a proble…

Byte array to string conversion

I’m making an Android app that communicates with bluetooth device. I’m writing a specific message to chosen characteristic as follows: My conversion function looks like this: I’m trying to figure out why in this case my conversion output looks like this: D/uploadDataset: Message: �����������…

java – creating 2D array (matrix) from two 1D arrays

Given How do I programmatically achieve: with Yes everything needs to be Object, Object[] or Object[][] due to upstream constraints ie. TestNG @DataProvider. Answer A couple of nested loops does the magic but the dimensions of the retVal are different: Test: Output (not pretty-printed): [[J, diamonds], [Q, di…