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
Tag: java
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…
Coding a propositional logic parser by hand
I need to do a parser for propositional logic. I pretend to do it by hand implemented like a recursive descent parser in java. My question is about the lexer, is it really needed for this job? I mean …
How to make clear that a parameter of a method serves as a return value?
Is there a way to show that a parameter of a method serves as return value? If I want to return one value it is no problem: public Set addIntegerToSet(final int i) { Set<Integer&…
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…
JavaFX “Location is required.” even though it is in the same package
I am trying to get my JavaFX program to run but am having some difficulty. I keep getting an error of ‘java.lang.NullPointerException: Location is required.’ The fxml file is in the same package as Application class. Here is my very simple code: And here is a copy of my main.fxml file: The control…
Copy image from JavaFX application and paste it using Windows
I am working on a JavaFX application. I want to copy image from application using context menu and paste it using Windows feature of paste. For example, like shown below in images. And want to paste at location from using of Windows features menu. Answer Use the Clipboard and ClipboardContent, e.g. as: For th…
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: […
Android: OutOfMemory error and the backstack
the following sheet represents the working flow in the application this question is about. I ran into problems with OutOfMemory Errors, mostly because users were able to switch from activity B to activity D multiple times (They are showing different content for every attempt), without the previous activity be…