Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.help Subject: Re: Convert a String to Int: can I use toInt() instead of Integer.parseInt()? Date: Wed, 06 Jul 2011 18:07:05 -0700 Organization: A noiseless patient Spider Lines: 18 Message-ID: References: <521s0711i3d7bsc8620isi0oiidl91kujq@4ax.com> <7an6179km7upsvba40ebe98gmfedg2414k@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 7 Jul 2011 01:07:10 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="5HSAJfqnDjjLFxXZ6WBWEw"; logging-data="10510"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Msd7F+hdDws3wt0evJKTbH/05MAbiYfM=" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 In-Reply-To: Cancel-Lock: sha1:c2ibtuAvo98vKmkZflz9oLzhdho= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.help:835 On 7/6/2011 4:53 PM, Patricia Shanahan wrote: > Or, of course, you could use the Character.digit method. It's a bit more > flexible, allowing a one line change e.g. to do hexadecimal instead of > decimal, and providing easy internationalization. This might work if paired with Character.getNumericValue(char ch), but the docs for getNumericValue did specifically mention digits for other languages that isDigit supports, so caveat emptor and be sure to test it carefully first. But I was being pedagogical here: it's very important (imo) to understand how the definition of the ASCII and Unicode standards can improve program effiency drastically. Folks here who claim to be experienced programmers seem to miss this idea.