Reputation: 79
I'm doing some code excercises before an exam in Java and I've stumbled upon a problem.
This is the output I want to get:
/\Oj, så många
/\leende och lyckliga
/\programmerare!
And the given code is:
public class Selektion_3_18 {
public static void main(String[] args) {
System.out.println("Oj, så många leende och lyckliga programmerare!");
}
}
I've tried googling the combination of back and forward slashes without getting a result.
My question is therefore; What is the functionality of /\? Or how am I supposed to use escape sequences to get the output they're asking for?
Upvotes: 2
Views: 1246
Reputation: 1249
Well, you could achieve something like:
System.out.println("/\\ Oj, så många\n/\\ leende och lyckliga\n/\\ programmerare!");
Forward-slash doesn't need escape as literal back-slash does,the back-slash is used to escape special characters, such as the one used in the above string \n. If you want to use a literal back-slash, a double back-slash must be used.
Upvotes: 1