NetBeans can be very helpful – sometimes toooo helpful which is why we start coding in jGRASP.
Here are some shortcuts to begin with . . .
- psvm <tab> – public static void main(String[]args)
- sout <tab> – System.out.println(” “)
- for <tab> – the simple for loop
- fori<tab> – for loop with an object array
- if <tab> – starts your if statement for you
- ifelse<tab> – if else statement
- wh<tab> – while loop
- do <tab> – the do while loop
- <alt> <shift> <f> – will sort out your horrible indenting
- bcom<tab. – /* */ multiple line comment
- trycatch <tab> – for the try . . . catch statement
- sw<tab> – switch case break statement
- <ctrl> <space> – when you place your cursor on the command you are having difficulty with, it will autosuggest everything about the command in question. Example – JOptionPane below.
<alt> <enter> – when the cursor is on a red underlined word, it will give helpful suggestions. See below
<alt> <insert> – will offer to insert code for you, like getters, setters, constructor, toString etc. See below.
For more shortcuts visit Tools, Options, Editor, Code Templates in NetBeans
PROBLEM: The wrong program runs . . .
You have a number of packages in your current project, each with their own main method. When you Run your program, the wrong main method runs! This is how you switch from one main method to another.
Click in the Project, right click, Properties, Run, Browse, select the main method you want to run. See below.