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
Solved

Converting String values to int

Posted on 2002-03-07
2
192 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
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 212
How to convert String matching to regex in java 4 49
Java exception bubble up 2 21
CSV file parsing thru Java 13 34
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

840 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