The Artima Developer Community
Sponsored Link

Java Answers Forum
JAVA CODE SNIPIT Question..

1 reply on 1 page. Most recent reply: Jul 10, 2005 11:26 PM by Kondwani Mkandawire

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Luke

Posts: 5
Nickname: locoluke
Registered: Jun, 2005

JAVA CODE SNIPIT Question.. Posted: Jul 10, 2005 2:44 PM
Reply to this message Reply
Advertisement
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));


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: JAVA CODE SNIPIT Question.. Posted: Jul 10, 2005 11:26 PM
Reply to this message Reply
> 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.

Flat View: This topic has 1 reply on 1 page
Topic: i need help... please!!!!!!!!!! Previous Topic   Next Topic Topic: looking for template tutorial

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use