为什么这些布尔值恢复为真?

时间:2019-04-29 00:43:22

标签: java android boolean

在这段代码中,我在boolean类中将这些false变量设置为Globals。但是,在运行时,当我通过在Activity中对其进行调用并将本地boolean设置为Globals boolean s的值时,它们会给出一个{{ 1}}的值。我不知道为什么会这样。

true类:

Globals

主要活动(省略了导入):

package com.example.ymarebuild;

import android.app.Application;

public class Globals extends Application {
    private static Globals instance;
    private static boolean u1t1 = false;
    private static boolean u1t2 = false;
    private static boolean u1t3 = false;
    private static boolean u1t4 = false;
    private Globals(){}

    public void setu1t1(boolean a){
        Globals.u1t1=a;
    }
    public boolean getu1t1(){
        return Globals.u1t1;
    }

    public void setu1t2(boolean a){
        Globals.u1t2=a;
    }

    public boolean getu1t2(){
        return Globals.u1t2;
    }

    public void setu1t3(boolean a){
        Globals.u1t2=a;
    }

    public boolean getu1t3(){
        return Globals.u1t3;
    }

    public void setu1t4(boolean a){
        Globals.u1t4=a;
    }

    public boolean getu1t4(){
        return Globals.u1t4;
    }

    public static synchronized Globals getInstance(){
        if (instance==null) {
            instance = new Globals();
        }
        return instance;
    }
}

0 个答案:

没有答案