是什么在Android的code长,长有什么区别? [英] What is the difference between long and Long in android code?

查看:128
本文介绍了是什么在Android的code长,长有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个Android应用程序的AsycTask。在那里,我遇到了整数和长数据类型,我不知道它们是什么。我试着用,但我得到了日食一个错误说

 令牌长语法错误,尺寸此令牌后,预计。


解决方案

龙是一类。长是一种原始。这意味着龙可以为空,在这里长不了。龙可以去任何地方,它接受一个对象,久不能(因为它不是它不会从Object派生类)。

Java的通常翻译一个长成一个长自动(反之亦然),但不会为空值(因为长期不能是长),你需要的时候,你需要通过使用长版本一类(如在通用声明)。

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'.

解决方案

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 long), and you need to use the Long version when you need to pass a class (such as in a generic declaration).

这篇关于是什么在Android的code长,长有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆