Difference between C: and C:/

后端 未结 2 1576
慢半拍i
慢半拍i 2021-01-18 10:49

I was just reading some java book and making some small programs for practice, I created a small code to get information about the path I entered, and the code is:



        
相关标签:
2条回答
  • 2021-01-18 11:00

    C: means "whatever directory is currently selected on drive C:". In your case, it's probably the directory that your application is running from.

    D: is the same as D:/ in your case because the root directory is the current working directory in D:.

    0 讨论(0)
  • 2021-01-18 11:18

    This is not really a java question, but a windows/dos question.

    The explanation comes down to the old dos command for switching drives.

    Typing a drive letter followed by a colon is a command to change drives in dos, therefore the 'command' C: does nothing since your working dir is already on the C drive. The 'directory' returned by the native interface to the JRE is the same as if you used the path "", ie your working directory.

    On the other hand, add a slash and it is a proper path, to the root of your C drive, therefore your JRE is given this directory by the native interface.

    If you go to a dos command (windows>run>cmd) and type in C: you will see that it accepts the command but does not change directory, unless of course you are currently on a different drive at the time.

    hope that helps.

    0 讨论(0)
提交回复
热议问题