[2403] in java-interest

home help back first fref pref prev next nref lref last post

Re: more casting (sort of)

daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Sat Sep 30 09:48:43 1995

Date: Fri, 29 Sep 1995 09:07:10 -0700
From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
To: lemay@lne.com
Cc: java-interest@java.Eng.Sun.COM


Hi Laura,

> So as I was playing with casting, I wanted to see how easy it was to
> convert an integer to a string and back again (part of my campaign
> for "useless examples." :)
> 
> Integer to string isn't so bad:
> 
> String str = String.valueOf(555);
> 
> But I can't figure out how to convert a string back to an int.  or a
> char.  or a boolean.
 
Try this:

	int i = Integer.valueOf(str).intValue();
	boolean b = str.equals("true");

Have fun,

	Arthur van Hoff
	
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post