Tuesday, November 23, 2010

How to create a new object in NetBeans

Another useful java code template is newo, that expands to the following:
Object obj = new Object();
As behind the curtains the expression is

${TYPE default="Object"} ${OBJ newVarName default="obj"} = new ${TYPE}(${cursor});
all you have to do is change the type and note how the IDE at the same time changes the name of the variable setting the first letter in lowercase, e.g. if you hit newo TAB MyObject the result will be
MyObject myObject = new MyObject();
Neat and clean :-)

4 comments:

Kris Scorup said...

That's nice. I've been using "n <tab>" for quite a while, but it doesn't change the variable name.

.MOz said...

Great! it works perfectly on my NetBeans 6.9.1! Thanks for the hint!

Amani Phoenix said...

It will definitely ease your work of handling a big project. As a project manager I use scrum in my projects. One of my friends referred me to use the Guide to Scrum Body of Knowledge by http://www.scrumstudy.com. I like the concepts of sprints, daily standup meetings, etc. the SBOK Helped me alot in Understanding how Agile Project Management works.

Miah Charley said...

After thinking over for quite a while about whether to go for PMP or SCRUM certification, I opted for a PMP prep course , Instructer was too good and I passed with relative ease. Looking forwards to apply what I learned in PMP classes in my company.