Java学习八,包装类

国产安全芯片在密码算法国密体系下的性能适配策略 国密体系即国家商用密码体系,是保障信息安全的核心技术体系。自20世纪90年代末起步,国密体系经历了从无到有、从弱到强的发展历程。1999年,国家密码管理局成立,标志着国密体系的正式建立。2000年,国密SM1算法首次发布,开启了国密算法的标准化进程。此后,SM2、SM3、SM4等算法陆续推出,形成了完整的对称与非对称密码算法体系。:2010年,国密标准正式纳入国家标准体系,国密算法在金融、政务、通信等关键领域的应用得到明确规范。 阅读详情

1.什么是包装类

   我们都知道,Java是oop的编程,但是我们八大基本数据类型中,如图下所示,是没有属性和方法的更加无法进行对象化的交互,所以应允而生了包装类;

                                   

                                                  

2.基本数据类型和包装类的转化

  2.1 装箱(基本数据类型-->包装类)

package com_imooc.baozhuanglei;

public class baozhuang_test {
    public static void main(String[] args) {
        //装箱
        //1.自动装箱
        int t =1;
        Integer t1=t;

        //2.手动装箱
        Integer t2=new Integer(t);
    }
}

  2.2 拆箱(包装类-->基本数据类型)

package com_imooc.baozhuanglei;

public class baozhuang_test {
    public static void main(String[] args) {
        //装箱
        //1.自动装箱
        int t = 1;
        Integer t1 = t;

        //2.手动装箱
        Integer t2 = new Integer(t);


        //拆箱
        //1.自动拆箱
        int t3 = t2;

        //2.手动拆箱
        int t4 = t2.intValue();         //转换成为int数据类型
        double t5 = t2.doubleValue(); //转换成为其他的数据类型
    }
}

3.基本数据类型和字符串的转化

package com_imooc.baozhuanglei;

public class baozhuang_test {
    public static void main(String[] args) {
        //装箱
        //1.自动装箱
        int t = 1;
        Integer t1 = t;

        //2.手动装箱
        Integer t2 = new Integer(t);


        //拆箱
        //1.自动拆箱
        int t3 = t2;

        //2.手动拆箱
        int t4 = t2.intValue();         //转换成为int数据类型
        double t5 = t2.doubleValue(); //转换成为其他的数据类型

        //转换为字符串
        String t6=Integer.toString(t2);

        //字符转换成基本数据类型
        int t7=Integer.parseInt(t6);

    }
}

4.实例

package com_imooc.baozhuanglei;

public class zhuyi {
    public static void main(String[] args) {
        Integer a = new Integer(100);
        Integer b = new Integer(100);
        System.out.println("a==b的结果是:" + (a == b)); //a和b是通过new创建的不同对象所以指针不同,所以不相等

        Integer c = 100;
        System.out.println("c==100的结果是:" + (c == 100));//自动拆箱后的动作,所以相等

        Integer d = 100;
        System.out.println("c==d的结果是:" + (c == d));//在缓存区(对象池)中的数据,相比来说100=100

        Integer e = 200;
        Integer f = 200;
        System.out.println("e==f的结果是:" + (e == f));//-128<缓存区(对象池)<127,超过了重新new对象,所以指针不同

    }
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

【异常】插入Milvus时出现无法插入的情况提示io.milvus.exception.ParamException: The field: meta is not provided. 在使用 Milvus 进行向量搜索时遇到 io.milvus.exception.ParamException: The field: meta is not provided 错误通常意味着在创建集合(Collection)或者插入数据(Insert)时,某些必需的元数据字段没有被正确提供。检查集合创建,确保在创建集合时,你已经定义了所有必需的字段,并且正确地使用了 SchemaField 来定义这些字段。例如,如果你在创建集合时没有正确设置元数据字段,就会出现这个错误。请严格按照这个表结构创建。 阅读详情

相关推荐

混沌系统在图像加密中的应用(二维离散Hénon混沌映射)

Hénon映射是一种二维离散时间动力系统,由美国数学家Michel Hénon在1976年引入。它是混沌动力系统中的经典模型之一,具有简单的形式和复杂的行为。

weixin_42207434的博客 2490

【Java学习笔记八】包装类和vector

包装类 在Java语言中,每一种基本的数据类型都有相应的对象类型,称为他们基本类型的包装类(包裹类)。 字节byte:Byte、短整数型short:Short 标准整数型int:Integer、长整数型long:Long 单精度实数型float:Float、双精度实数型double:Double 布尔型boolean:Boolean、字符型char:Character、无类型void:Void 在...

T_T233333333的博客 358

Ubuntu 22.04源码编译安装ROS Noetic

Ubuntu 22.04源码编译安装ROS Noetic

Drknown的博客 2万+

【java学习—八】包装类和toString(3)

父类Object的toString方法就是输出当前对象的内存地址(如果想要输出类的其他信息,重写toString方法)举例:(MyDate.java和Test.java在包day08中):JDK1.5 之后,支持自动装箱,自动拆箱。针对八种基本定义相应的引用类型—包装类(封装类)重点:基本数据类型的包装类:主要作用就是。有了类的特点,就可以调用类中的方法。基本数据类型与字符串直接的转化。

weixin_44883789的博客 203

告别手动点鼠标:用Python脚本批量跑ADS版图仿真,效率提升10倍(附完整代码)

本文详细介绍了如何利用Python脚本自动化ADS版图仿真流程,显著提升射频工程师的工作效率。通过调用ADS底层接口,实现参数化修改、批量任务调度和结果自动收集,解决了手动操作中的常见问题,如仿真不更新等。附完整代码,帮助开发者快速实现10倍效率提升。

weixin_42523543的博客 332

Crazyflie 2.1固件刷写与地址配置全攻略:从开箱到连接Crazyswarm

本文详细介绍了Crazyflie 2.1微型无人机的固件刷写、地址配置及与Crazyswarm系统的集成方法。从开箱检查到多机协同飞行,涵盖了硬件准备、固件刷写、无线电地址修改等关键步骤,帮助用户快速实现集群飞行控制。特别针对Crazyswarm系统集成提供了实用配置示例和调试技巧。

weixin_42530458的博客 405

Java SE 学习笔记(八)—— 包装类与泛型

包装类与泛型

hu_wei123的博客 796

27、自闭症儿童治疗与玩具设计研究

本研究探讨了自闭症儿童的治疗方法与玩具设计之间的关联,分析了游戏疗法、音乐疗法和职业疗法等在治疗中的应用,并介绍了多种针对自闭症儿童的治疗玩具案例。通过用户研究和多学科合作,提出了以Pro-Ability为核心的设计理念,开发了结合音乐疗法和精细运动训练的智能玩具套件。研究总结了当前成果与局限性,并展望了未来发展方向,旨在为自闭症儿童提供更有效的康复支持。

keras9composer的博客 211

java学习笔记(八)时间,包装类(补发)

【代码】java学习笔记(八)时间,包装类(补发)

qq_63317320的博客 535

《网络安全自学教程》- SQL注入之报错注入原理+步骤+实战操作

这篇文章为大家解析报错注入的实现原理,结合实战案例讲解报错注入的使用步骤。

wangyuxiang946的博客 1万+

【一看就会】Autoware.universe中静态绕障路线的生成逻辑

在路径行为规划中,前期根据地图和起点终点,生成了一组连续可行的路径段序列(lanelets),然后后续路径行为规划,又会进行起始点,终止点,避障绕障路径的路径规划,并且会调用route_handler中的函数,进行中心线生成,最后生成路径,后续再给速度行为规划进行速度规划。在autoware.universe的规划中,是基于规则的规划,而其中的规则又是为了解决不同场景的。而这些场景,大部分是为了解决路上障碍物(静态、动态、行人、车辆等等)。

weixin_48386130的博客 321

Java学习笔记(八)--基本数据类型包装类 Math类 Random类 Date类

基本数据类型包装类1.为了方便基本类型的数据做更多的操作,java就针对每种基本数据类型给出了对应的类类型,这就是我们所说的基本类型的包装类。 2.Integer类型 -字段: MAX_VALUE:值为2^31-1的常量,它表示int类型能够表示的最大值。 MIN_VALUE:值为-2^31的常量,它表示int类型能够表示的最小值。-构造方法: Integer(int value):构造一

yangruxi的博客 562

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

Java--包装类的学习

本文介绍了Java中的包装类-- 什么是包装类 ,包装类和基本数据类型之间的关系转换 --装箱与拆箱,包装类的valueOf和XXValue以及构造方法的总结 , 自动装箱和拆箱以及触发的情况 , 包装类内里的缓存机制, 包装类一些相关练习题和面试题

记录并分享学习编程时的知识点... 3297

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Java——八大包装类

Java中的包装类缓存机制是为了优化性能和节省内存而设计的。它为整型(Byte、Short、Integer、Long)、字符型(Character)和布尔型(Boolean)的包装类提供了缓存,确保在这些类型的小范围值之间可以复用对象。而对于浮点数类型的包装类(Float、Double),则没有这种缓存机制,意味着每次都需要创建新的对象。这样一来,Java在处理常用值时更加高效,但在浮点数处理上则相对简单直接。

Stewie Lee的博客 3604

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

【Java】Java 包装类详解

Java包装类是八种基本数据类型对应的对象类,使其能用于泛型、集合等场景。主要特点包括自动装箱/拆箱、常用值缓存机制(如Integer缓存范围为-128到127),以及提供字符串转换等实用方法。使用时需注意==比较的陷阱、空指针风险及性能消耗。推荐通过valueOf()创建包装类对象,利用缓存提升效率。

经天纬地,格物致理 1740

Java的包装类

一、包装类分类 Java有八种基本数据类型:byte、short、int、long、float、double、boolean、char Java为其提供了8种对应的包装类:Byte、Short、Integer、Long、Float、Double、Boolean、Character Integer num = new Integer(0); //创建一个数值为0的Integer对象 二、使用包装类的原因 Java语言是面向对象的编程语言,而基本数据类型声明的变量并不是对象,为其提供包装类,增

weixin_46140377的博客 1万+

JAVA 包装类

Java 包装类

qq_53312143的博客 5256

Java的包装类有哪些,包装类的作用

在上一篇文章中我们给大家介绍了**Java中的Object类**,它属于我们开发时的常用类。除此之外,还有另外的一些常用类,比如各种包装类。**那么包装类又是怎么回事?有哪些类属于包装类?包装类的作用是干嘛的?包装类有哪些特性?** 接下来这篇文章就给大家讲一讲这些包装类。

关注我!带你一路 "狂飙" 到底! 2491

java char 包装类_Java 包装类

1、Java 包装类Java有8种基本数据类型:整型(byte、short、int、long)、浮点型(float、double)、布尔型boolean、字符型char,相对应地,Java提供了8种包装类Byte、Short、Integer、Long、Float、Double、Boolean、Character。包装类创建对象的方式就跟其他类一样。包装类提供了一种使用原始数据类型作为对象的方法。下...

weixin_39725193的博客 5603

【Java学习】包装类

每个基本数据类型都有对应的基本类型的包装类变量基本数据类型对应的包装类对象类与对象面向对象体系。实例化包装类对象时,可以通过new Integer(int)实例化创建一个包含这个整数的包装类的似复刻变量,但我们一般都使用Integer类变量里面的静态方法valueOf(int)来实例化创建包上它这个整数的包装类对象

Brookty的博客 816

JAVA包装类——(包装类介绍以及包装类的常用方法)

一:什么是包装类: 包装类就是把基本类型数据转换为对象,为什么要进行转换:1:集合和数组的区别就是集合中存储的都是对象,不能是基本类型的数据:2:需要运用一些实用的方法,通过对象点出来,比如后面用到的 String words="123"; words.length;可以点出一些方法; 基本类型的数据和引用类型的数据的区别一个是基本类型的数据都是小写,并且基本类型的数据点(.)不出来属性和方法;为了满足一些需求,就需要把基本类型数据转换成对象,就出现了包装类; 每一个基本类型在java.

gitets的博客 2088

《JAVA SE》包装类

阿里巴巴编码规范:所有POJO(普通)类的成员变量一律使用包装类代替基本类型。

VIBE的博客 1383

Java包装类详解

包装类的意义 Java是一门面向对象的语言,但是Java的八种基本数据类型却没有对象的特征,更没有对象的功能(没有属性,不能调用方法) 基本数据类型不能调用方法,这就给我们很多的操作带来不便,另外容器(例如List、HashMap等)基本接收存储的都是 Object,不能接收基本数据类型。为了解决这个问题我们就要把所谓的基本数据类型包装成对象,使其具有对象的特征来方便使 用 clas...

qq_42006733的博客 1524

Java包装类

在-

2301_81354580的博客 1066

JAVA包装类

用于表示整数数值,不包含小数部分。byte用于表示带小数的数值,分为单精度和双精度。float用于表示单个 Unicode 字符,占 16 位。char。

m0_61261153的博客 1117

java学习中,包装类,异常

顺带一提我们可以建立自己的自定义异常类,根据不同的异常名称,判断异常的错误。public class 异常类名 extends Exception {public 异常类名(String msg){super(msg);

mhjnmh的博客 903
上一篇: Java学习七,异常处理
下一篇: Java学习九,字符串和集合
yí無所冇
博客等级 码龄9年 78粉丝 92原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值