Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>That's because <code>*</code> is a shell wildcard: it has a special meaning to the shell, which expands it before passing it on to the command (in this case, <code>java</code>).</p> <p>Since you need a literal <code>*</code>, you need to escape it from the shell. The exact way of escaping varies depending on your shell, but you can try:</p> <pre><code>java ProgramName 5 3 "*" </code></pre> <p>Or:</p> <pre><code>java ProgramName 5 3 \* </code></pre> <hr> <p>By the way, if you want to know what the shell does with the <code>*</code>, try printing the content of <code>String[] args</code> to your <code>main</code> method. You'll find that it will contain names of the files in your directory.</p> <p>This can be handy if you need to pass some filenames as command line arguments.</p> <h3>See also</h3> <ul> <li><p><a href="http://en.wikipedia.org/wiki/Glob_%28programming%29" rel="noreferrer">Wikipedia: glob</a></p> <blockquote> <p>For example, if a directory contains two files, <code>a.log</code> and <code>b.log</code> then the command <code>cat *.log</code> will be expanded by the shell to <code>cat a.log b.log</code></p> </blockquote></li> <li><p><a href="http://en.wikipedia.org/wiki/Escape_character" rel="noreferrer">Wikipedia: Escape character</a></p> <blockquote> <p>In Bourne shell (<code>sh</code>), the asterisk (<code>*</code>) and question mark (<code>?</code>) characters are wildcard characters expanded via globbing. Without a preceding escape character, an <code>*</code> will expand to the names of all files in the working directory that don't start with a period if and only if there are such files, otherwise <code>*</code> remains unexpanded. So to refer to a file literally called <code>"*"</code>, the shell must be told not to interpret it in this way, by preceding it with a backslash (<code>\</code>).</p> </blockquote></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload