Netbeans configuration - arguments not recognised in ide
I'm working my way through the Java in 24 hours book (which is actually quite good) and have hit a problem in that the simple test programs aren't recognising the arguments I put in the configuration window, i'm following the instructions exactly as written and have tried with different code snippets to no ava开发者_JAVA百科il.
This is the latest script, note the 'No arguments println...
class newSqrt {
public static void main(String[] args) {
int number = 144;
if (args.length > 0) {
number = Integer.parseInt(args[0]);
} else {
System.out.println("No arguments!");
}
System.out.println("The square root of "
+ number + " is " + Math.sqrt(number));
}
}
I pasted a screenshot of the configuration clearly showing the argument 100 so I should see the square root of 100 but I get the output below clearly proving that it is just ignoring the argument from the configuration. I'm sure i'm not the only one who has had this happen, I have tried various google searches but nothing has helped track down the problem.
run:
No arguments! The square root of 144 is 12.0 BUILD SUCCESSFUL (total time: 0 seconds)Right-Click on the top-most node of your project in the Projects tab, and click on Properties.
In the Project Properties, click on Run, and then in Arguments: enter an appropriate value. Then click on OK
Run the project by clicking on the Run toolbar button (or through the Run menu). If prompted for the main class, select newSqrt. You should see the appropriate output.
精彩评论