Solved

StringToken to integer conversion

Posted on 2000-05-13
1
185 Views
Last Modified: 2010-04-01
Is there any possibility to convert the value that comes from stringTokenizer to an integer value ?
I'am reading a simple string of integer values and then I want to tokenise it and put the values into integer variables.
0
Comment
Question by:ssdjgru1
1 Comment
 
LVL 2

Accepted Solution

by:
Nevyn earned 200 total points
ID: 2806779
Use class Integer.

StringTokenizer tok = ...;
int value = Integer.parseInt(tok.nextToken());
The parseInt method takes a String argument, and may throw a NumberFormatException is the string contains invalid characters for a number. There are similar methods available for the Double, Float, etc in the java.lang package. Check out the codumentation for details.
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 45
MySQL  on Tomcat 8 46
check java version using powershell 13 93
mysql jsp example issue 32 38
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

810 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