-3

Hi Stackoverflow community

I have been trying to find a resource or reference that explains what the usage() method does. Unfortunately the word 'usage' is indexed so often in different contexts that I simply can't find a good resource. Would anybody be able to point me in the right direction?

public static void main(String[] args) {
        if (args.length == 0) {
            usage(); 
        } else if ("parse".equals(args[0])) {
            final String[] parseArgs = new String[args.length - 1];
             etc ....

I know that in C getusage() is used to get memory and CPU usage statistics. Is this the same case in Java? Any pointers would be highly appreciated. Mike

Mike Nedelko
  • 709
  • 1
  • 8
  • 28
  • This method is very likely to be in your code and will print out an error message as you have not provided any runtime arguments when some are expected. – Scary Wombat Sep 05 '16 at 05:50
  • 1
    there is no usage() inbuilt method in java. this method seems to be specific to your application. – dhS Sep 05 '16 at 05:51
  • There are **command line options** libraries that might provide as an extra a usage function, though that would need to be localized. Search those. – Joop Eggen Sep 05 '16 at 05:56

2 Answers2

2

usage() is not a built in Java function. Your post includes an invocation that is presumably intended to display information about command line arguments.

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
1

usage is not coming from any library or so.

Typically, such methods are written to print "how to use this tool" information for command line tools; upon user running the tool with "-h", "--help"; or after he provided invalid / missing command line arguments. In other words: the person who created that main class/method ... also wrote the usage method.

In that sense: this is a good opportunity for you to learn how to navigate your java source code. Simply search for the declaration of this method to understand what it is doing!

GhostCat
  • 137,827
  • 25
  • 176
  • 248