Issue
I was trying to write an AsycTask in an android application. There I came across Integer and Long data types and I am not sure what they are. I tried using long
in place Long
, but I got an error in eclipse saying
'Syntax error on token "long", Dimensions expected after this token'.
Solution
Long is a class. long is a primitive. That means Long can be null, where long can't. Long can go anywhere that takes an Object, long can't (since it isn't a class it doesn't derive from Object).
Java will usually translate a Long into a long automatically (and vice versa), but won't for nulls (since a long can't be a null), and you need to use the Long version when you need to pass a class (such as in a generic declaration).
Answered By - Gabe Sechan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.