Reputation: 113
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?
Upvotes: 0
Views: 634
Reputation: 12937
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);
Upvotes: 3