my dog learned polymorphism*
The moose likes Cattle Drive and the fly likes (String) casts in SortNames Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "(String) casts in SortNames" Watch "(String) casts in SortNames" New topic
Author

(String) casts in SortNames

Peter Gragert
Ranch Hand

Joined: Jan 16, 2001
Posts: 424
My environment is too stupid to make distinction between
casts and identifiers.
So I got "( String ) object" by 'beautifying' and got nitpicked a number of times.
So do not do that, read the style guide again!
Paul Ralph
Ranch Hand

Joined: Aug 10, 2000
Posts: 312
You aren't allowed to make casts from Object to String?
Paul R
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
You can cast an Object to a String if the Object was originally a String that was stored as an Object.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Peter Gragert
Ranch Hand

Joined: Jan 16, 2001
Posts: 424
What I meant is: '(String)object' versus '( String ) object'
Styleguide conformance, you see three spaces? ;-)
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
I'm not sure I understand,
  • (String)object <- the nitpickers way ?
  • ( String ) object <- your way ?

  • The first one is correct, see 2.2 - Spacing

    This is true. -- Marilyn


    [This message has been edited by Johannes de Jong (edited June 01, 2001).]
    [This message has been edited by Marilyn deQueiroz (edited June 01, 2001).]
Michael Pearson
Ranch Hand

Joined: Mar 11, 2001
Posts: 351
Thanks to the style guide (and Marilyn reminding me) I learned this lesson.
Now that I use the style guide format it makes it a lot easier to spot a cast in my code.
Michael
Peter Gragert
Ranch Hand

Joined: Jan 16, 2001
Posts: 424
Hello Michael,
You mean a regular expression: '(\w+)' (emacs)?!
No answer necessary.
Have a nice weekend
Peter
 
Don't get me started about those stupid light bulbs.
 
subject: (String) casts in SortNames
 
Similar Threads
For Each LOOP Question
Help I can't stop this thread then restart
spacing error ?
Doubt in Strings
Autoboxing occurs at Runtime or Compile time .