IntelliJ IDEA love affair
It continues… IDEA 5 has some fantastic new stuff in it, but like most IDEA releases it takes a while to notice the really impressive ones.
Today I found a great feature. I was coding something like this:
public class MyClass
{
static
{
MY_DATA.put( "x", 5);
MY_DATA.put( "y", 7);
};
}
I then put the cursor on MY_DATA as it did not exist. I used CTRL-ENTER to trigger the intention window, and selected "Introduce Constant". Idea then produced this (my Java language level is 5.0):
public class MyClass
{
private static final Map<String, Integer> MY_DATA = ;
static
{
MY_DATA.put( "x", 5);
MY_DATA.put( "y", 7);
}
}
Notice how it not only guessed the type of the constant based on the constant’s usage, but also deduced the key and value types. Needless to say it let me autocomplete the constant assignment to new HashMap<String, Integer>()
Recent Comments