Its a simple question, I have a String like this:
String s = "'\n'";
I want to turn that into a character like this:
char c = '\n';
What can I do?
There are three characters, first is ', second is \n and third is '. You can get the second one using .charAt(1) since it is zero based indexing:
String s = "'\n'";
char ch = s.charAt(1);
char ch = (char) (1 << 3 | 1 << 1);, what's the point? ;) I guess there are even more confusing ways of assigning a newline to a char
char c = '\n';instead of picking a single char out of a string? I can't really see any use case for this..