Re: String to Integer
- From: Mark Space <markspace@xxxxxxxxxxxxxx>
- Date: Sat, 21 Jun 2008 07:45:21 -0700
adam wrote:
Lew wrote:
Integer i = '\n';
is what you want.
Thanks for answering so quickly!
The thing is that I have a String var with characters such as "0", "a", "\n"... I use String.charAt(0) for getting the first character of the string. It works nice when I'm using a normal character ('0', 'a'...) but it doesnt with escape characters (it gets '\' instead of '\n').
So the question is: how can convert a string "\n" into an integer?
Or how can I convert "\n" into a char for then converting it to an integer??
\n is an escape sequence for string and character literals. If read from a file or the keyboard, the IO system does not assume that you really meant a \ to mean something else, it just reads what is there. If you want a newline in a file or at the keyboard, hit Enter.
I don't know of Java class that will parse string literal escapes for you. Considering there's only a few of them, doing it yourself should not be hard.
.
- References:
- String to Integer
- From: adam
- Re: String to Integer
- From: Lew
- Re: String to Integer
- From: adam
- String to Integer
- Prev by Date: Re: Starting a java class through a bat file
- Next by Date: Re: Impossible Exception
- Previous by thread: Re: String to Integer
- Next by thread: Re: String to Integer
- Index(es):
Relevant Pages
|