Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Madeleine Hughes   on Jul 22 In Java Category.

  
Question Answered By: Daimon Jones   on Jul 22

Directly u can't cast  a String variable  into a Long.
Becoz String is an immediate child of Object class, so u can't directly cast
String into any other types except an Object class.
(Def. u know Object is the parent of all classes, so virtually u can't cast
a String variable into other types)
IF I AM WRONG PLZ LET ME KNOW...

But there are very simple,static methods like
new Long(String)
Long.parseLong(String)

which will return long  values.
u can use these to convert a String value to Long (Wrapper class) /
long(primitive).

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on casting in java Or get search suggestion and latest updates.


Tagged: