File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Cast a String to a long? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cast a String to a long?" Watch "Cast a String to a long?" New topic

Cast a String to a long?

Michael Brewer
Ranch Hand

Joined: Jun 27, 2002
Posts: 54
Is it possible to cast a String to a long? I first looked for String methods that would allow me to do this, and then I tried doing this:

That gives me an 'inconvertible types' error.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Check out the parseLong() method in the Long class. It takes a String arguemnt and returns a long (primitive).

I agree. Here's the link:
subject: Cast a String to a long?
It's not a secret anymore!