Skip to content

Tag: java

How can I shuffle the letters of a word?

What is the easiest way to shuffle the letters of a word which is in an array? I have some words in an array and I choose randomly a word but I also want to shuffle the letters of it. I am not supposed to use that List thing. I’ve come up with something like this but with this code

Delete highlighting in JComboBox

When a JComboBox is just made and added and all the background of the selected item is just normal and white: (ignore the enormous spacing after the text) When I then open the list and hover my cursor over an item, that item get’s highlighted, all normal, nothing wrong with it. But the problem now is th…

Mockito when method not working

I am using mockito as mocking framework. I have a scenerio here, my when(abc.method()).thenReturn(value) does not return value, instead it returns null. } Java class When ever i run the test file the when is not working and i am using mockito1.8.5 jar in the buildpath. The service call is being mocked but ret…

Collect successive pairs from a stream

Given a stream such as { 0, 1, 2, 3, 4 }, how can I most elegantly transform it into given form: { new Pair(0, 1), new Pair(1, 2), new Pair(2, 3), new Pair(3, 4) } (assuming, of course, I’ve defined class Pair)? Edit: This isn’t strictly about ints or primitive streams. The answer should be genera…

Resolve a dependency on package sun.misc with Tycho

I try to convert a Buckminster-based build to Tycho (0.19.0). In our (mirrored) target platform we have the bundle com.lmax.disruptor from http://lmax-exchange.github.io/disruptor/ which imports the package “sun.misc” When I try to build our own bundle (that depends on com.lmax.disruptor) I get: […