会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132884个问题
WEB前端全系列/第二阶段:JavaScript编程模块/DOM模型 20313楼

package com.itbaizhan;
import java.util.Arrays;//自定义一个简单的包装类,仅限于练习
public class MyInteger {
    private final int value;
    private static MyInteger[]cache;//缓存【-128,127】之间的数字
    private static  final int LOW=-128;
    private static  final  int HIGH=127;
    static {
        cache=new MyInteger[HIGH-LOW+1];
        for(int i=LOW;i<HIGH;i++){
            cache[i-LOW]=new MyInteger(i);
        }
        System.out.println(Arrays.toString(cache));
    }
    public MyInteger(int value){
        this.value=value;
    }
    @Override
    public String toString() {
        return value+"";
    }
    public static MyInteger valueof(int value){
        if(value>=LOW&&value<=HIGH){
            return  cache[value-LOW];
        }
        return  new MyInteger(value);}
    public static void main(String[] args) {
        MyInteger a=new MyInteger(10);
        MyInteger b= new MyInteger(100);
        MyInteger b2= new MyInteger(100);
        MyInteger b3 = new MyInteger(1000);
        MyInteger b4 = new MyInteger(1000);
        System.out.println(b==b2);
        System.out.println(b3==b4);
        int c=b.intvalue();  }
    public int intvalue(){
        return  value;
    }
}

不清楚为什么会输出两个false

JAVA 全系列/第二阶段:JAVA 基础深化和提高/常用类 20316楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/智能电话本项目实战 20319楼
Python 全系列/第五阶段:数据库编程/python操作mysql 20320楼
JAVA 全系列/第十八阶段:亿级高并发电商项目_架构/编码(旧)/电商:基于SpringSecurity实现后台登录功能 20321楼
Python 全系列/第九阶段:Flask百战电商后台系统/Flask百战电商后台项目 20324楼
Python 全系列/第一阶段:Python入门/编程基本概念 20325楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637