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?
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);