Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

##Misleading Message?

Misleading Message?

 if (args.length != 1) {
 System.err.println("No arguments provided.");
 System.exit(1);
 }

So if I have 2 arguments, I get the message No arguments provided. Umm... I provided 2 arguments!

###Suggested fix:

Suggested fix:

Change the above code to:

 if (args.length == 0) {
 System.err.println("No arguments provided.");
 System.exit(1);
 }

And you can possible warn the user about only requiring one argument if they provide too much. Something like:

 if (args.length > 1) {
 System.out.println("Warning! Too many arguments; only the first one will be considered.");
 }

##Misleading Message?

 if (args.length != 1) {
 System.err.println("No arguments provided.");
 System.exit(1);
 }

So if I have 2 arguments, I get the message No arguments provided. Umm... I provided 2 arguments!

###Suggested fix:

Change the above code to:

 if (args.length == 0) {
 System.err.println("No arguments provided.");
 System.exit(1);
 }

And you can possible warn the user about only requiring one argument if they provide too much. Something like:

 if (args.length > 1) {
 System.out.println("Warning! Too many arguments; only the first one will be considered.");
 }

Misleading Message?

 if (args.length != 1) {
 System.err.println("No arguments provided.");
 System.exit(1);
 }

So if I have 2 arguments, I get the message No arguments provided. Umm... I provided 2 arguments!

Suggested fix:

Change the above code to:

 if (args.length == 0) {
 System.err.println("No arguments provided.");
 System.exit(1);
 }

And you can possible warn the user about only requiring one argument if they provide too much. Something like:

 if (args.length > 1) {
 System.out.println("Warning! Too many arguments; only the first one will be considered.");
 }
Source Link
TheCoffeeCup
  • 9.5k
  • 4
  • 38
  • 96

##Misleading Message?

 if (args.length != 1) {
 System.err.println("No arguments provided.");
 System.exit(1);
 }

So if I have 2 arguments, I get the message No arguments provided. Umm... I provided 2 arguments!

###Suggested fix:

Change the above code to:

 if (args.length == 0) {
 System.err.println("No arguments provided.");
 System.exit(1);
 }

And you can possible warn the user about only requiring one argument if they provide too much. Something like:

 if (args.length > 1) {
 System.out.println("Warning! Too many arguments; only the first one will be considered.");
 }
lang-java

AltStyle によって変換されたページ (->オリジナル) /