> Java help #2?

Java help #2?

Posted at: 2014-12-18 
how would i write a an output statement which will output the following characters exactly as shown: /'\''/'\

Source:

public class Example {

public static void main(String[] args) {

System.out.println("/\'\\\'\'/\'\\");

}

}

Output:

$ java Example

/'\''/'\

In a string literal, you need to precede each special character with a backslash if you want to output it as is. Your string contains two special characters: the backslash and the double quote. So you need to tell Java to print "/’\\\"/'\\".

System.out.println("/'\\''/'\\");

I'm assuming that the '' part of the string is two single quotes next to each other (as you specified in the question), not a double quote.

how would i write a an output statement which will output the following characters exactly as shown: /'\''/'\