|
Re: JAVA CODE SNIPIT Question..
|
Posted: Jul 10, 2005 11:26 PM
|
|
> Could someone explain the following code snip-it as best > they could. My real question and confusion lies within the > "@param" and "@return". What, in laymans terms does the > "@param token" and the "@return true..." mean. I can't > seem to figure out what the @ represents. Obviously I am > not a programmer...but am in the process of learning. > Thanks in advance. > > /** > * Checks if the specified string is an operator or not. > * @param token > * @return true if specified string is an operator. > */ > private static boolean isOperator(char ch) > { > String token = String.valueOf(ch); > return ("+".equals(token) || > "-".equals(token) || > "/".equals(token) || > "*".equals(token));
@param token is simply a Java doc standard. Its a style of commenting and is not essential to the code from an execution stand point (its a comment and is hence to help the programmer understand the code better).
In fact it should actually read @param ch because that is the parameter that is take in, token is only defined within the method and is not a parameter.
@returns true is also standard Java doc. It means that when a particular token encountered in the given String is an operator, then the method returns true.
The other stuff is algorithmic
return "+".equals(token) compares the String "+" and the String version of ch which is referenced by the variable token. It returns true if the values held by the two references being compared are equal and false otherwise.
|
|