The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

String to int

Posted by Tim W. on September 28, 2001 at 10:00 AM

Does anyone know of a good method to turn a String, "1" for instance, into the equivalent int?

I'm currently doing the following:

String foo;
int bar = (new Integer(foo)).intValue();

It's only one line of code, but having to create an object each time I want the primitive int value irritates me.

Thanks,

Tim W





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us