aspose file tools
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

Win a copy of Elasticsearch in Action this week in the Big Data forum!
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).

Don't get me started about those stupid light bulbs.
subject: Cast a String to a long?