The moose likes Beginning Java and the fly likes How to read numbers in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to read numbers in java" Watch "How to read numbers in java" New topic

How to read numbers in java

teja dharma
Ranch Hand

Joined: Feb 07, 2009
Posts: 51
How to read numbers in java ?

[edit]Get rid of large red font. CR[/edit]

Himalay Majumdar
Ranch Hand

Joined: Sep 28, 2008
Posts: 324
Click here.

I suggest its better to do your homework..research on the topic first, before asking questions. Also..Please try using normal font.

SCJP 1.6, SCWCD 5.0, SCBCD 5.0 [loading..]
K. Tsang

Joined: Sep 13, 2007
Posts: 3132

What context are you basing your question on? If you want to convert strings to numbers (integer, double etc) then you can use Integer.parseInt(String) or Double.parseDouble(String) etc

The other way round is to use the toString() method of Integer or Double class.

K. Tsang JavaRanch SCJP5 SCJD OCPJP7 OCPWCD5 OCPBCD5 OCPWSD5 OCMJEA5 part 1 part 2/3
Angelika Angley
Ranch Hand

Joined: Feb 17, 2009
Posts: 40
From left to the right!

[Blog] [SCJP6 75%] [SCBCD]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46397
Agree about "normal font." But "left-to-right" is a bit steep, thank you. And we aren't that fond of the "let me Google that for you site." It is however, good for a laugh to try that link and see what it produces

K Tsang is right about Integer.parseInt() and Double.parseDouble(); in fact there are similar methods in most of the subclasses of the Number class (or the subclass constructors) for getting numbers out of Strings.
You can also read a number from a text file, keyboard input, etc, with the nextXXX() methods of the Scanner class.

I agree. Here's the link:
subject: How to read numbers in java
It's not a secret anymore!