File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "(String) casts in SortNames" Watch "(String) casts in SortNames" New topic

(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

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

"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

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.
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
I agree. Here's the link:
subject: (String) casts in SortNames
It's not a secret anymore!