• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Seperator character

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Following question is from JQ+

Q: Which of these statements about the constant named 'seperator' of the File class are true?
Options:
1. It is of type char.
2. It is of type String.
3. Its value is "\" for Windows and "/" for Unix.
4. It is always 1 char.
5. It may be composed of more than 1 char.

Correct answers are 2, 3,4.
I thought seperator is of type char and not String.
I found following in the API documentation.

public static final String separator
The system-dependent default name-separator character, represented as a string for convenience. This string contains a single character, namely separatorChar.

Could somebody tell me whether it is of type char or String?
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well seema i dont clearly understand what the doubt is
but from the API it seems the constant
1. separator is represented as a String
2. separatorChar is represented as a char
hope that helps
Samith.P.Nambiar
------------------------------------------
the harder u try the luckier u get
------------------------------------------
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is a String. Ref: Books KM, RHE
 
Seema Das
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My confusion is, API says it is a system dependent character, represented as a String for convinience. THat means it is a character in java. only the output is in String for our convinience.
 
Samith Nambiar
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi seema
system dependant as in "
<bold> On UNIX systems the value of this field is '/'; on Win32 systems it is '\'. <bold> " ... thats it .
yes it is a character in java (i.e separatorChar ).... only the output is in String (i.e separator) for our convinience.
hope that helps
Samith.P.Nambiar
------------------------------------------
the harder u try the luckier u get
------------------------------------------

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,
The reason for the separator being string is simple!
String is on account of "immutabity", and ofcource it is made to be of one char only as per the convention for OS.
Hope I am able to drive my point.
Ravindra Mohan.
[This message has been edited by Ravindra Mohan (edited May 11, 2001).]
reply
    Bookmark Topic Watch Topic
  • New Topic