Solved

Converting String values to int

Posted on 2002-03-07
2
197 Views
Last Modified: 2010-03-31
I need an efficient way of converting a String value (that represents a number) to an int value. The values come from a file that's read in so I'll never know what the number is. They are a part of a vector
for example: 0   2   1   4   3
This vector is parsed and the individual values are placed into Strings. How do I take String "n" and convert it to int n where String "n" may be "2" (or could be any number)?
0
Comment
Question by:webratss
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
Venci75 earned 50 total points
ID: 6847020
use:
int i_num = Integer.parseInt("343");

or

long l_num = Long.parseLong("94343");
0
 

Author Comment

by:webratss
ID: 6847042
Worked perfectly! Thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question