1

In this method the symbol value can be anything Stock Symbol like (For example GOOG , C , DAC-----etc)

private boolean isC(String symbol) {
    char code = symbol.charAt(symbol.length() - 2);
    return code <= 'L';
}

Could anybody please let me know what does this return type mean exactly ??

I am confused because i was thinking of a return type to be either true or false, but could anybody please let me know what does this 'L' mean exactly ??

Thanks in advance .

2
  • 1
    The return value is the value of the boolean expression code <= 'L'. Java chars are comparable. Commented Jul 6, 2012 at 10:08
  • 'L' is represented also as an integer value (pl.wikipedia.org/wiki/ASCII). 'L' is equal to 0x4C. method isC returns result of comaprision Commented Jul 6, 2012 at 10:12

3 Answers 3

3

returns true if the ascii code of the character in the variable 'code' is less than or equal to the ascii code for L.

false otherwise

1
  • Thank yo very much all , my bad i was seeing at from 30 feet high .
    – Pawan
    Commented Jul 6, 2012 at 10:12
0

Because you have a condition stated after the return keyword the condition is getting evaluated first and the result of the evaluation is then getting returned.

And because a condition can only be true or false the return type of this method is boolean.

Here when you apply the <= operator with the type char you are comparing the numerical ASCII representation of a char.

0

You can see the ascii code of some of the characters here. code <= 'L' is a comparison between the ascii code of the value of code and 'L'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.