Equivalent of C# anonymous methods in Java?

Pre Java 8: The closest Java has to delegates are single method interfaces. You could use an anonymous inner class. interface StringFunc { String func(String s); } void doSomething(StringFunc funk) { System.out.println(funk.func(“whatever”)); } doSomething(new StringFunc() { public String func(String s) { return s + “asd”; } }); doSomething(new StringFunc() { public String func(String s) { … Read more

Empty an array in Java / processing

There’s Arrays.fill(myArray, null); Not that it does anything different than you’d do on your own (it just loops through every element and sets it to null). It’s not native in that it’s pure Java code that performs this, but it is a library function if maybe that’s what you meant. This of course doesn’t allow … Read more

Can’t find a way to color the Mandelbrot-set the way i’m aiming for

First take a look at this related QA: Mandelbrot Set – Color Spectrum Suggestions? The main idea is to use histogram to distribute the color gradients more effectively to used indexes instead of uniformly wasting many colors on unused indexes. Also it uses a specific visually pleasing gradient function: RGB values of visible spectrum Dynamic … Read more