I worked on a project that uses a framework. To add a new sub class I had to make the base class, that is part of the framework, open for extension. I was able to compile the framework on my own without the need to create a local artifact repository then create a new artifact and new version by the… Read more →
Java
JavaFX Gluon Ignite Guice Inject Controller
I had to inject a whole controller into another controller with the guice implementation of gluon ignite. I will show an approach doing so. This is applicable if you have set the controller id in your fxml. Otherwise this snipped requires slightly modifications. I assume you have ignite already running and injecting stuff already but facing the “inject a controller… Read more →
Generate Javadoc with UML Diagrams
It is very useful to have UML Diagrams integrated into your javadoc – they give you a neat visual overview of the contents of you sourcecode. I want to show you how to integrate this into an automated build. I implemented this with an ant target and my IDE Netbeans. Add this to your build.xml in the root of your… Read more →
toString(), equals() Contract
Any Object is an Object or a child of an Object as described in the Java Language Specification: The class Object is a super class (§8.1) of all other classes. A variable of type Object can hold a reference to the null reference or to any object, whether it is an instance of a class or an array (§10). All… Read more →
For – Know the difference
I would like to write some words about the difference of the for loop behaviour. At first you should read the code and notice 2 different for usages. Both should do the same. Do they?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | public class Main { /** * @param args */ public static void main(String[] args) { String[] blablubb = { "a", "b", "c" }; // 1) for(String s : blablubb) { s = "over"; } printArray(blablubb); // 2) for (int i = 0; i < blablubb.length; i++) { blablubb[i] = "over"; } printArray(blablubb); } public static void printArray(String[] arr) { for( String s : arr ) { System.out.println(s); } } } |
I assumed the first loop would also overwrite the string in the array – as the second one does. But it does not! –… Read more →