布尔VS在Java中boolean [英] Boolean vs boolean in Java

查看:205
本文介绍了布尔VS在Java中boolean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有在Java中围绕整数讨论VS INT 。前者的默认值为而后者是 0 。如何布尔 VS 布尔

There are discussion around Integer vs int in Java. The default value of the former is null while in the latter it's 0. How about Boolean vs boolean?

在我的应用程序中的变量可以有 0 / 1 值。我想用布尔 / 布尔和preFER不使用 INT 。我可以用布尔 / 布尔呢?

A variable in my application can have 0/1 values. I would like to use boolean/Boolean and prefer not to use int. Can I use Boolean/boolean instead?

推荐答案

您可以使用布尔 / 布尔代替。

Yes you can use Boolean/boolean instead.

第一个是对象和第二个是基本类型。

First one is Object and second one is primitive type.


  • 在第一个,你会得到更多的方法,这将是有益的。

  • 二是考虑到价格便宜的内存开销。

现在选择自己的方式。

这篇关于布尔VS在Java中boolean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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