aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Seperator character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Seperator character" Watch "Seperator character" New topic
Author

Seperator character

Seema Das
Ranch Hand

Joined: Mar 05, 2001
Posts: 78
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

Joined: Mar 14, 2001
Posts: 147
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

Joined: Jan 28, 2001
Posts: 153
It is a String. Ref: Books KM, RHE
Seema Das
Ranch Hand

Joined: Mar 05, 2001
Posts: 78
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

Joined: Mar 14, 2001
Posts: 147
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

Joined: Mar 16, 2001
Posts: 216
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).]
 
 
subject: Seperator character