Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cast a String to a long?

 
Michael Brewer
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael
Check out the parseLong() method in the Long class. It takes a String arguemnt and returns a long (primitive).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic