-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

3
  • 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. Commented Sep 5, 2016 at 5:50
  • 1
    there is no usage() inbuilt method in java. this method seems to be specific to your application. Commented Sep 5, 2016 at 5: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. Commented Sep 5, 2016 at 5:56

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

2

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!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.