浙江高端网站建设公司/如何优化培训方式
Arrays
概述
提供了数组操作的相关方法,连接数组和集合
asList
- 返回指定数组的列表
- 列表和数组的引用位置相同
Integer[] arrs = new Integer[] {1,2,3,4,5,6,7,8,9};List<Integer> list = Arrays.asList(arrs);System.out.println(list);arrs[5] = 100;System.out.println(list);//[1, 2, 3, 4, 5, 6, 7, 8, 9]//[1, 2, 3, 4, 5, 100, 7, 8, 9]}
binarySearch
- 二分法查找元素
- 需要进行排序
Integer[] arrs = new Integer[] {1,2,3,4,5,6,7,8,9};int num = Arrays.binarySearch(arrs, 5);System.out.println(num);
//4
copyOf copyOfRange
- 创建数组副本
- 一个新的数组
Integer[] arrs = new Integer[] {1,2,3,4,5,6,7,8,9};Integer[] arrs1 = Arrays.copyOf(arrs, 5);for(Integer i : arrs1) {System.out.print(i + " ");}System.out.println();//1 2 3 4 5 arrs1[3] = 100;for(Integer i : arrs) {System.out.print(i + " ");}//1 2 3 4 5 6 7 8 9 System.out.println();for(Integer i : arrs1) {System.out.print(i + " ");}//1 2 3 100 5 Integer[] ret = Arrays.copyOf(arrs,20,Integer[].class);System.out.println();for(Integer i : ret) {System.out.print(i + " ");}//1 2 3 4 5 6 7 8 9 null null null null null null null null null null nullInteger[] range = Arrays.copyOfRange(arrs, 5, 20);System.out.println();for(Integer i : ret) {System.out.print(i + " ");}//1 2 3 4 5 6 7 8 9 null null null null null null null null null null null
equals deepEquals
- deepEquals 是深层次的比较,比如嵌套数组
Integer[] arrs = new Integer[] {1,2,3,4,5,6,7,8,9};Integer[] arrs1 = new Integer[] {1,2,3,4,5,6,7,8,9};System.out.println(arrs);System.out.println(arrs1);System.out.println(Arrays.equals(arrs, arrs1));
// [Ljava.lang.Integer;@2077d4de
// [Ljava.lang.Integer;@7591083d
// true
Arrays.fill填充数组
public void test5() {Integer[] arrs = new Integer[10];Arrays.fill(arrs, 100);for(Integer i : arrs) {System.out.print(i + " ");}//100 100 100 100 100 100 100 100 100 100 }
sort
public void test6() {Integer[] arrs = new Integer[20];for(int i=0;i<20;i++)arrs[i] = (int)(Math.random()*100);for(int i:arrs) {System.out.print(i + " ");}System.out.println();//49 40 0 79 4 98 12 81 71 27 9 45 16 17 7 92 63 22 73 22 Arrays.sort(arrs);for(int i:arrs) System.out.print(i + " ");System.out.println();//0 4 7 9 12 16 17 22 22 27 40 45 49 63 71 73 79 81 92 98 Arrays.sort(arrs,(o1,o2)->o2-o1);for(int i:arrs) System.out.print(i + " ");//98 92 81 79 73 71 63 49 45 40 27 22 22 17 16 12 9 7 4 0 }
parallelSort
- 经过比较 速断快与sort
- 使用频率越高越明显
- 数据量越大越明显从1000~10000000开始进行100次测试
public void test7() {//生产1万个元素int len = 100000;Integer[] arrs = new Integer[len];for(int i=0;i<len;i++)arrs[i] = (int)(Math.random()*100);long t1 = System.currentTimeMillis();Arrays.sort(arrs);long t2 = System.currentTimeMillis();System.out.println("sort\t"+(t2-t1));for(int i=0;i<len;i++)arrs[i] = (int)(Math.random()*100);long t3 = System.currentTimeMillis();Arrays.parallelSort(arrs);long t4 = System.currentTimeMillis();System.out.println("parallelSort\t"+(t4-t3));System.out.println("------------------------------");}
public void test8() {for(int i=0;i<100;i++) {test7();}}
sort 35
parallelSort 64
------------------------------
sort 40
parallelSort 73
------------------------------
sort 107
parallelSort 53
------------------------------
sort 73
parallelSort 63
------------------------------
sort 74
parallelSort 62
····
····
spliterator 遍历数组
int len = 100;Integer[] arrs = new Integer[len];for(int i=0;i<len;i++)arrs[i] = (int)(Math.random()*100);Spliterator<Integer> s = Arrays.spliterator(arrs);s.forEachRemaining((e)->System.out.print(e + " "));
Stream
public void test10() {int len = 10;Integer[] arrs = new Integer[len];for(int i=0;i<len;i++)arrs[i] = (int)(Math.random()*100);List<Integer> list = Arrays.stream(arrs).collect(Collectors.toList());System.out.println(list);//[56, 33, 59, 63, 55, 37, 68, 52, 53, 3]}
setAll parallelSetAll 为所有的元素赋值
- parallelSetAll 并行处理,速度会快
public void test11() {int len = 10;Integer[] array = new Integer[len];Arrays.setAll(array, (e)->10);for(int i:array)System.out.print(i + " ");System.out.println();Arrays.parallelSetAll(array, (e)->e + 10);for(int i:array)System.out.print(i + " ");// 10 10 10 10 10 10 10 10 10 10
// 10 11 12 13 14 15 16 17 18 19 }
parallelPrefix 每个元素都包含对前面的所有元素应用某个操作的累计结果
public void test12() {int len = 10;int[] array = new int[len];Arrays.parallelPrefix(array, (e,u)->{System.out.println(e + "\t" + u);return e +1;});System.out.println();for(int i:array)System.out.print(i + " ");}
toString deepToString(嵌套数组) hashCode deepHashCode
public void test13() {int len = 10;Integer[] arrs = new Integer[len];for(int i=0;i<len;i++)arrs[i] = (int)(Math.random()*100);System.out.println(Arrays.toString(arrs));System.out.println(Arrays.hashCode(arrs));}
相关文章:
![](https://www.ngui.cc/images/no-images.jpg)
Arrays 的使用
Arrays 概述 提供了数组操作的相关方法,连接数组和集合 asList 返回指定数组的列表列表和数组的引用位置相同 Integer[] arrs new Integer[] {1,2,3,4,5,6,7,8,9};List<Integer> list Arrays.asList(arrs);System.out.println(list);arrs[5] 100;Syste…...
![](https://img-blog.csdnimg.cn/direct/0493b63ee5294c359feca6d2c40fb586.png)
IDEA中怎么用Postman?这款插件你试试
Postman是大家最常用的API调试工具,那么有没有一种方法可以不用手动写入接口到Postman,即可进行接口调试操作?今天给大家推荐一款IDEA插件:Apipost Helper,写完代码就可以调试接口并一键生成接口文档!而且还…...
![](https://img-blog.csdnimg.cn/direct/ae82f667369b4889bfb400d6eca19b8f.png)
基于机器视觉的车牌检测-边缘检测因子的选择
车牌检测概述 车牌识别在检测报警、汽车出入登记、交通违法违章以及移动电子警察方面应用广泛。车牌识别过程为:首先通过摄像头获取包含车牌的彩色图像;然后进行车牌边缘检测,先粗略定位到车牌位置,再精细定位;最后根…...
![](https://img-blog.csdnimg.cn/b9d41c16b3404d528af23dc739292711.jpg)
学习c语言,变种水仙花
利用函数次方pow...
![](https://img-blog.csdnimg.cn/direct/dee43d9b92d04b93be257bf7e6b43646.png)
K8S--持久卷(PersistentVolume)的用法
原文网址:K8S--持久卷(PersistentVolume)的用法-CSDN博客 简介 本文介绍K8S的持久卷(PersistentVolume)的用法。 目标:用持久卷的方式将主机的磁盘与容器磁盘映射,安装nginx并运行。 --------------------------------------------------…...
![](https://img-blog.csdnimg.cn/direct/645bf7fb04b940f5aa32c299f50cc87f.png)
书生·浦语大模型趣味 Demo笔记及作业
文章目录 笔记作业基础作业:进阶作业: 笔记 书生浦语大模型InternLM-Chat-7B 智能对话 Demo:https://blog.csdn.net/m0_49289284/article/details/135412067书生浦语大模型Lagent 智能体工具调用 Demo:https://blog.csdn.net/m0_…...
![](https://img-blog.csdnimg.cn/img_convert/a0b9435ced011257f8e8ac6999031165.png)
2024最新前端源码分享(附效果图及在线演示)
分享10款非常有趣的前端特效源码 其中包含css动画特效、js原生特效、svg特效以及小游戏等 下面我会给出特效样式图或演示效果图 但你也可以点击在线预览查看源码的最终展示效果及下载源码资源 粒子文字动画特效 基于canvas实现的粒子文字动画特效 会来回切换设定的文字特效 图…...
![](https://img-blog.csdnimg.cn/img_convert/d54c18371b5522c5300942ec8aed0037.png)
Microsoft 365 for Mac激活版(原Office 365)
Microsoft 365 for Mac原office 365,包含Word、Excel、PowerPoint 和 Outlook应用程序,协作办公的最佳首选。 软件下载:Microsoft 365 for Mac激活版下载 Microsoft 365 的一些主要功能包括: office 应用程序:Microsof…...
![](https://img-blog.csdnimg.cn/img_convert/772293e698cfe00cbc79de7681c5c778.png)
快乐学Python,Python基础之组织代码「类与对象」
在上一篇文章中,我们了解了函数。这一篇文章我们来了解一下Python中另外一个重要的概念:类与对象。 1、类与对象 (1)类与对象有什么关系? 你可能会奇怪,为什么要叫类与对象呢?是两个不同的东…...
![](https://www.ngui.cc/images/no-images.jpg)
H5的3D游戏开源框架
在H5的3D游戏框架中,Three.js、Babylon.js和Turbulenz是比较受欢迎的选择。 Three.js是一个广泛应用并且功能强大的JavaScript 3D库,可以创建简单的3D动画到创建交互的3D游戏。 Babylon.js是David Catuhe对3D游戏引擎热爱的结果,是最好的Ja…...
![](https://www.ngui.cc/images/no-images.jpg)
浅谈一些生命周期
vue2生命周期 beforeCreate :实例创建之初 created:组件已经创建完成 beforeMount:组件挂载之前 mounted:组件挂载之后 beforeUpdate:数据发生变化 更新之前 undated:数据发生之后 beforeDestroy :实…...
![](https://img-blog.csdnimg.cn/direct/39d100d639594013a36ce97e88315262.png)
JavaScript基础(25)_dom查询练习(二)
<!DOCTYPE html> <html lang"zh"> <head><meta charset"UTF-8"><title>dom查询练习二</title><link rel"stylesheet" href"../browser_default_style/reset.css"><style>form {margi…...
![](https://img-blog.csdnimg.cn/direct/a24529ef96c44f05974bf67a81f81dd4.png)
【React系列】React生命周期、setState深入理解、 shouldComponentUpdate和PureComponent性能优化、脚手架
本文来自#React系列教程:https://mp.weixin.qq.com/mp/appmsgalbum?__bizMzg5MDAzNzkwNA&actiongetalbum&album_id1566025152667107329) 一. 生命周期 1.1. 认识生命周期 很多的事物都有从创建到销毁的整个过程,这个过程称之为是生命周期&…...
![](https://img-blog.csdnimg.cn/direct/44ea762277a147a386574450f4aff3d4.png)
一文初步了解slam技术
本文初步介绍slam技术,主要是slam技术的概述,涉及技术原理、应用场景、分类、以及各自优缺点,和slam技术的未来展望。 🎬个人简介:一个全栈工程师的升级之路! 📋个人专栏:slam精进之…...
![](https://img-blog.csdnimg.cn/direct/e52c3164db9040a1a20ef80e96533121.png)
滑动窗口协议仿真(2024)
1.题目描述 滑动窗口协议以基于分组的数据传输协议为特征,该协议适用于在数据链路层以及传输层中对按 顺序传送分组的可靠性要求较高的环境。在长管道传输过程(特别是无线环境)中,相应的滑动窗口 协议可实现高效的重传恢复。附录 …...
![](https://www.ngui.cc/images/no-images.jpg)
uniapp上传文件时用到的api是什么?格式是什么?
在UniApp中,你可以使用uni.uploadFile()方法来上传文件。这是一个异步方法,用于将本地资源上传到服务器。 该方法的基本格式如下: uni.uploadFile({url: 上传接口地址,filePath: 要上传的文件路径,name: 后端接收的文件参数名,formData: {/…...
![](https://img-blog.csdnimg.cn/direct/d4c0bf4c308d4e8cb6da4fc12fde095a.png)
Java面试——框架篇
1、Spring框架中的单例bean是线程安全的吗? 所谓单例就是所有的请求都用一个对象来处理,而多例则指每个请求用一个新的对象来处理。 结论:线程不安全。 Spring框架中有一个Scope注解,默认的值就是singleton,单例的。一…...
![](https://img-blog.csdnimg.cn/direct/d2d18b66a6664bfc999ad3430e8f132c.png)
GO语言笔记1-安装与hello world
SDK开发工具包下载 Go语言官网地址:golang.org,无法访问Golang中文社区:首页 - Go语言中文网 - Golang中文社区下载地址:Go下载 - Go语言中文网 - Golang中文社区 尽量去下载稳定版本,根据使用系统下载压缩包格式的安装…...
![](https://img-blog.csdnimg.cn/direct/072516a5332a489094708f6395fbf209.png)
指针传参误区
C语言中指针作为形参传递时,func(*a, *b) 这种形式的话,是无法通过简单的 ab来修改的,在函数体内a的地址确实被修改成b的地址了,但是当函数执行结束时,a的地址会重新回到原本的地址里面…...
力扣-42.接雨水
题目: 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 示例 1: 输入:height [0,1,0,2,1,0,1,3,2,1,2,1] 输出:6 解释:上面是由数组[0,1,0,2…...
![](https://img-blog.csdnimg.cn/direct/c9621fadc56a4354b91f33a8e8a84257.png)
LeetCode-移动零(283)
题目描述: 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 请注意 ,必须在不复制数组的情况下原地对数组进行操作。 思路: 这里的思路跟以前做过的去重复数字的思路有点像&…...
![](https://img-blog.csdnimg.cn/direct/cd9cfa90f78942e1bf456e335c34d82f.png)
文件系统与日志分析
一,文件系统 (一)inode 和block概述 1,文件数据包括元信息与实际数据 2,文件存储在硬盘上,硬盘最小存储单位是“扇区”,每个扇区存储512字节 3,block (块) 连续的八个扇区组成一…...
![](https://img-blog.csdnimg.cn/img_convert/1f8330782ed7d7d7d9566eb2c87df9e6.png)
labview 与三菱FX 小型PLC通信(OPC)
NI OPC服务器与三菱FX3U PLC通讯方法 一、新建通道名称为:MIT 二、选择三菱FX系列 三、确认端口号相关的参数(COM端:7.波特率:9600,数据位:7,校验:奇校验,停止位…...
![](https://www.ngui.cc/images/no-images.jpg)
掌握Linux网络配置:价格亲民,操作简便!
前言 在Linux系统中,网络配置是实现连接、通信和安全的重要一环。无论你是初学者还是有经验的用户,掌握网络配置命令能帮助你轻松管理网络接口、设置IP地址以及查看连接状态。以下是一些关键命令和示例,让你快速掌握网络操作的精髓ÿ…...
![](https://img-blog.csdnimg.cn/direct/25a90dfbfe394815bc835fb30b08c3c9.png)
郑州大学算法设计与分析实验2
判断题 1 #include<bits/stdc.h> using namespace std;const int N 50; int f[N], n;int main() { // freopen("1.in", "r", stdin);ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cin >> n;f[1] 1; f[2] 1;for(int i 3; i &l…...
![](https://img-blog.csdnimg.cn/direct/a14abdfeb89645afbda8328f1a6cc6bc.png)
【CMake】1. VSCode 开发环境安装与运行
CMake 示例工程代码 https://github.com/LABELNET/cmake-simple 插件 使用 VSCode 开发C项目,安装 CMake 插件 CMakeCMake ToolsCMake Language Support (建议,语法提示) 1. 配置 CMake Language Support , Windows 配置 donet 环境 这…...
![](https://www.ngui.cc/images/no-images.jpg)
使用vue3+<script setup>+element-plus中el-table前端切片完成分页效果
<template><div><el-table :data"visibleData" :row-key"row > row.id"><el-table-column prop"name" label"姓名"></el-table-column><el-table-column prop"age" label"年龄&qu…...
![](https://www.ngui.cc/images/no-images.jpg)
vue 中 computed 和 watch 的区别
在Vue中,computed和watch都是用于监听数据的变化,并且根据变化做出相应的反应。 computed是一个计算属性,它会根据依赖的数据的变化自动计算得出一个新的值,并且具有缓存的特性。当依赖的数据发生变化时,computed属性…...
![](https://img-blog.csdnimg.cn/direct/38d5594fe68240f587144a18d167afae.png)
gephi——graphviz插件设置
gephi_graphviz插件设置 以下是我总结出来的一点经验 1. 安装graphviz软件,请见作者其他博客 2. 安装gephi 插件,并激活 3. 运行graphviz布局,会遇到找不到dot问题 问题描述:Graphviz process error X There was an error launc…...
![](https://img-blog.csdnimg.cn/916e3ec81d0b4fada9d427193dfbc9ed.png)
wireshark抓包分析HTTP协议,HTTP协议执行流程,
「作者主页」:士别三日wyx 「作者简介」:CSDN top100、阿里云博客专家、华为云享专家、网络安全领域优质创作者 「推荐专栏」:对网络安全感兴趣的小伙伴可以关注专栏《网络安全入门到精通》 使用WireShark工具抓取「HTTP协议」的数据包&#…...