• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

operators - Strings

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q) Which operators are overloaded for String Objects ?
I think
+
+= and
.(dot operator)
Any corrections , please.
But the BOOne exam answers only + , += How?
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
eram,
In Java the foll are separators.
(){}[];,.
So .(dot) is a separator. It is NOT an operator.
regds
maha anna
 
eram
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maha,
So this means obj.equals(obj1) , here the '.' is a seperator and not an operator.
Thanks
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eram, "." IS considered Object member access OPERATOR.
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jane, From which source , you say so.
please check here in JLS specifically 3.11 section
regds
maha anna
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Acc. to David Flanagan("Java in a Nutshell"):


There are five language constructs in Java that sometimes considered operators and sometimes considered simply part of the basic language syntax...
1. object member access(.)
2. array element access([])
3. method invocation (())
4. object creation(new)
5. type conversion or casting(())


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
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all.
I think I would rather go by JLS.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic