Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java equivalent of C#'s verbatim strings with @

Quick question. Is there an equivalent of @ as applied to strings in Java:

For example I can do @"c:\afolder\afile" in C# and have it ignore the escape characters when processing instead of having to do "c:\\afolder\\aFile". Is there a Java equivalent?

hmmm: stackoverflow is escaping on me .. lol. The second example should read:

c:(double-backslash)afolder(double-backslash)aFile

like image 205
Simon Rigby Avatar asked Apr 20 '10 09:04

Simon Rigby


People also ask

Is Java similar to C?

C is a middle-level language as it binds the bridges between machine-level and high-level languages. Java is a high-level language as the translation of Java code takes place into machine language, using a compiler or interpreter. C is only compiled and not interpreted. Java is both compiled and interpreted.

Is Java similar to C or C++?

These two languages are very similar in terms of syntax and language features. They are so similar that if you're shown some portion of C++ code from a project and asked whether it's C++ or Java code, you may confuse yourself.

Is Java built on C?

The very first Java compiler was developed by Sun Microsystems and was written in C using some libraries from C++. Today, the Java compiler is written in Java, while the JRE is written in C.

How different is C and C in Java?

C is a compiled language that is it converts the code into machine language so that it could be understood by the machine or system. Java is an Interpreted language that is in Java, the code is first transformed into bytecode and that bytecode is then executed by the JVM (Java Virtual Machine).


1 Answers

No. Escaping / externalizing the string is your only choice.

like image 126
Kent Boogaart Avatar answered Sep 21 '22 15:09

Kent Boogaart