Author | Topic: operators - Strings |
eram ranch hand |
posted March 19, 2000 02:52 PM
Q) Which operators are overloaded for String Objects ? I think Any corrections , please.
|
maha anna bartender |
posted March 19, 2000 03:10 PM
eram, In Java the foll are separators. ( ) { } [ ] ; , . So .(dot) is a separator. It is NOT an operator. regds maha anna
|
eram ranch hand |
posted March 19, 2000 03:13 PM
Maha, So this means obj.equals(obj1) , here the '.' is a seperator and not an operator.
|
maha anna bartender |
posted March 19, 2000 03:22 PM
yes. Simillarly in the pacakge and import statements also .(dot) acts as a separator. And when we refer a member of a class like you mentioned. package myPack1.myPack2.myPack3; import java.util.*; regds maha anna [This message has been edited by maha anna (edited March 19, 2000).]
|
Jane Rozen ranch hand |
posted March 19, 2000 03:27 PM
Eram, "." IS considered Object member access OPERATOR.
|
maha anna bartender |
posted March 19, 2000 03:35 PM
Jane, From which source , you say so. please check here in JLS specifically 3.11 section regds maha anna
|
Jim Yingst sheriff |
posted March 19, 2000 03:59 PM
Even if the . is considered an operator (and I think M.A. is correct that it isn't), I don't see how it is "overloaded" for Strings. Specific methods may be overloaded, but the . itself just what it always does for objects, right?
|
Jane Rozen ranch hand |
posted March 19, 2000 04:24 PM
Acc. to David Flanagan("Java in a Nutshell"): quote: I did not try to imply that "." is overloaded for String, just that it sometimes is considered to be a special type of operator.
|
Jim Yingst sheriff |
posted March 19, 2000 04:46 PM
Sorry Jane - I didn't mean to imply that you had said otherwise; I just was going back to eram's original question. Off-topic alert: the following is not going to come up on an exam, so don't worry about it unless you're interested. I like Flanagan's Java in a Nutshell (at least, the earlier parts that aren't completely superfluous compared to the online API) but in this case I'm inclined to think the JLS outranks him. I wonder who exactly is using this alternate terminology? C/C++ programmers who haven't read the JLS perhaps? Or perhaps there are documents from Sun somewhere that perpetuate this usage - after all, Sun's JDK is written in C, and the people who made it could well have used C terminology when describing it, unaware that the JLS had amended it in this case. Oh well...
|
eram ranch hand |
posted March 19, 2000 05:08 PM
Thanks to all. I think I would rather go by JLS.
|
| | |