Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Code (JAVA) Snip-it question...


  • Please log in to reply

#1
BigBadTex

BigBadTex

    New Member

  • Member
  • Pip
  • 3 posts
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));
  • 0

Advertisements


#2
ratmilk

ratmilk

    Member

  • Member
  • PipPipPip
  • 151 posts
I don't think there are a lot of Java programmers in this forum :tazz:
  • 0

#3
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 875 posts
/**
* Checks if the specified string is an operator or not.
* @param token
* @return true if specified string is an operator.
*/

this is a javadoc statement which is used for documentaion of code. notice that this block of code is commented. the compiler does nothing with this code. there is a javadoc generator which creates documentation from this code.

@param is a javadoc term. the '@' symbol is part of the term. @param is followed by a parameter and its description. several parameters(variables/fields) may be listed.

@return describes the return value.

for more javadoc info look here:
sun
java tools
  • 0

#4
kool808

kool808

    Visiting Staff

  • Member
  • PipPipPipPip
  • 1,690 posts
/**
* Checks if the specified string is an operator or not.
* @param token
* @return true if specified string is an operator.
*/

bdlt is correct these are just comments, shall we call it instructions or description of how a code works.

private static boolean isOperator(char ch)
{
<statements>;
}

This is a function which will return a boolean result of TRUE(1) if the input is an operator, otherwise if not operator then FALSE(0). The char ch is a formal parameter passed on to the function, which is of course the character you inputted, that is of data type character.

String token = String.valueOf(ch);
return ("+".equals(token) ||
"-".equals(token) ||
"/".equals(token) ||
"*".equals(token));

String token is a variable of data type string, the character you inputted is evaluated as (+,-,*,/) then it is passed to the variable. The symbol || is the other word for OR.
  • 0

#5
ratmilk

ratmilk

    Member

  • Member
  • PipPipPip
  • 151 posts
Oops, looks like i was wrong :tazz:
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP