English 中文(简体)
Boolean vs boolean(s) as trileanchange
原标题:Boolean vs boolean(s) as trilean switches

我正在开发一种安乐器,我刚刚开始做一些事情。 我有一些匿名的课堂(听众)。 这些参数从数据库中计算。 我这样做了:

buttonA.setOnTouchListener(new View.OnTouchListener() {
                        private Boolean isActive = null;
                        private boolean isTrigger;
                        private int onLevel;
                        private int offLevel;
                        private int chIdx;

                        @Override
                        public boolean onTouch(View v, MotionEvent event) {
                            if (isActive == null) {
                                Cursor btnSettings = dbHelper.getButtonsTable().fetchButton(1, profileId, currentMode);
                                ...
...
                            }
                            return true;
                        }

是否认为这是将波拉兰物体作为三角交换(如果听器的吨数被计为参数,则其价值无效)或我应当使用两种ean变......或可能是一种愤怒?

你们是否有想法?

最佳回答

然而,最好使用一种类型(可能是一卷),准确描述这三个国家。 农民没有向担任这一职务的人(特别是在作为三州时)提供很多信息。

public enum ActiveStatus {
  On,
  Off,
  Unknown
}
问题回答

我要说的是,要么以真实、虚假和无效的方式使用诱杀器,要么使用um。 我倾向于把“ know”作为“ know”一类。 如果你把“无知”当作比“无知”更有意义的事的话,那么你很可能在心中做得更好。

在此,我们必须使用一个变量来代表三个地位价值观中的任何一种:国家、外国或外国或挪威。 我们也知道,变数不能取得除这三个价值观以外的任何价值。 因此,我们可以说,这三个价值观是地位变数可以绘制成图的各种价值观。 当我们想到其他数据类型时,例如斜线、果园等,它们也有预先界定的价值观。 因此,在这种情况下,我们需要形成一种习俗数据类型,其范围包括三个价值。 这些数字用于这些假设情景,可定义为:

public enum ActiveState {
    ON, OFF, UNKNOWN
}

In Java 8 I d recommend to use Optional<Boolean>:

//Declaration:
Optional<Boolean> v;

//Setting:
v = Optional.empty(); //null
v = Optional.<Boolean>empty(); //null again
v = Optional.of(true);
v = Optional.of(false);
// (you may declare Trileans class with these constants)

//Checking:
if (v.isPresent()) /*v is not null*/;
if (v.isPresent() && v.get()) /*v is true*/;
if (v.isPresent() && !v.get()) /*v is false*/;
if (v1.equals(v2)) /*v1 and v2 are the same*/;
// (you may declare Trileans class with more operations)

安德森也许可以写上你自己的选修课(但不能肯定这是否是最佳解决办法)。

<代码>null不是“未具体说明价值”,而是任何物体的“无价值”——包括<代码>Boolean。 因此,在使用<代码>Boolean物体时,你仍然只有两个有意义的数值。

你们要么使用不止一艘蓝色旗或 en。

我认为这是良好做法。

Your data type is true or false or unspecified, nullable Boolean fits perfectly.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签