File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes help regarding escape character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help regarding escape character" Watch "help regarding escape character" New topic
Author

help regarding escape character

Venu Chakravorty
Ranch Hand

Joined: Aug 19, 2009
Posts: 46
hi,
i get a compile time error upon compiling:



perhaps because "\d" is not an escape character, where as in the next code:



"/d" gets printed when i invoke - java A "\d".
in the later case doesn't the String "\d" get assigned to "args[0]"? or maybe i am getting no error because i am trying to assign a value at runtime?

regards, venu
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
The values passed to the program are escaped by the JVM ...


JDBCSupport - An easy to use, light-weight JDBC framework -
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

The only thing that's relevant here is that to write an actual '\' character inside a String in Java source code, you must double it:

args[0] = "\\d";

The same goes for character constants:

char c = '\\';

There's no "escaping" of characters read from the command line or from files; a \ is just an ordinary character at runtime. Escaping is just used to turn off the special meaning of the \ character in source code.


[Jess in Action][AskingGoodQuestions]
Venu Chakravorty
Ranch Hand

Joined: Aug 19, 2009
Posts: 46
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help regarding escape character