Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Seperator character

 
Seema Das
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • 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?
 
Samith Nambiar
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • 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
------------------------------------------
 
tvs sundaram
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
------------------------------------------

 
Ravindra Mohan
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • 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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic