反射应用简单案例

day40

反射应用

案例

1.万能数组扩容

设置泛型的copyof仅支持引用数据类型,即任意类型,直接new数组不行,利用反射实现扩容;

打印调用toString也进行编写,利用StringBuffer或者StringBiulder进行字符串拼接

public class Test01 {public static void main(String[] args) {//引用数据类型String[] ss = {"小小","大大","奇奇","怪怪","奇男子"};String[] newSS = MyArrays.copyOf(ss, 8);System.out.println(MyArrays.toString(newSS));//基本数据类型int[] is = {1,2,3,4,5};int[] newIS = MyArrays.copyOf(is, 8);System.out.println(MyArrays.toString(newIS));}
}

对前面学习的数组,编写的工具类补充

/*** 史上最牛逼的数组工具类* @author 奇男子* @version 1.0*/
public class MyArrays {/*** 数组的排序* @param a 目标数组*/public static void sort(int[] a){for (int i = 0; i < a.length-1; i++) {for (int j = 0; j < a.length-1-i; j++) {if(a[j] > a[j+1]){int temp = a[j];a[j] = a[j+1];a[j+1] = temp;}}}}/*** 数组的查找,必须先排序,在查找* @param a 目标数组* @param key 需要查找的键* @return 如果搜索的元素包含在数组中就返回元素的下标; 否则,返回(-插入点-1)*/public static int binarySearch(int[] a,int key){int start = 0;int end = a.length-1;while(start <= end){int mid = (start+end)/2;if(key < a[mid]){end = mid-1;}else if(key > a[mid]){start = mid+1;}else{return mid;}}return -start-1;}/*** 拷贝数组* @param original 目标数组* @param newLength 新数组的长度* @return 新数组*/public static int[] copyOf(int[] original, int newLength){int copyLength = original.length;if(copyLength > newLength){copyLength = newLength;}int[] newArr = new int[newLength];for (int i = 0; i < copyLength; i++) {newArr[i] = original[i];}return newArr;}/*** 引用数据类型数组的扩容(不支持基本数据类型)* @param original* @param newLength* @return*/public static <T> T[] copyOf(T[] original , int newLength){int copyLength = original.length;if(copyLength > newLength){copyLength = newLength;}//获取元素的类型Class<? extends Object[]> clazz = original.getClass();//String[].classClass<?> componentType = clazz.getComponentType();//String.clss//利用反射创建数组@SuppressWarnings("unchecked")T[] ts = (T[]) Array.newInstance(componentType, newLength);//遍历源数组,将数据复制到新数组中for (int i = 0; i < copyLength; i++) {//获取源数组的数据Object element = Array.get(original, i);//赋值给新数组Array.set(ts, i, element);}return ts;}/*** 拷贝区间数组* @param original 目标数组* @param from 开始下标-包含* @param to 结束下标 - 排他* @return 新数组*/public static int[] copyOfRange(int[] original, int from, int to){int newLength = to-from;int[] newArr = new int[newLength];int index = 0;for (int i = from; i < to; i++) {newArr[index++] = original[i];}return newArr;}/*** 替换全部元素* @param a 目标数组* @param val 替换的值*/public static void fill(int[] a, int val){fill(a, 0, a.length, val);}/*** 替换区间元素* @param a 目标数组* @param fromIndex 开始下标 - 包含* @param toIndex 结束下标 - 排他* @param val 替换的值*/public static void fill(int[] a, int fromIndex, int toIndex, int val){for (int i = fromIndex; i < toIndex; i++) {a[i] = val;}}/*** 将数组转换为字符串* @param a 目标数组* @return 转换后的字符串*/public static String toString(int[] is) { StringBuffer sb = new StringBuffer();sb.append("[");for (int element : is) {if(sb.length() != 1){sb.append(",");}sb.append(element);}sb.append("]");return sb.toString();}/*** 将数组转换为字符串* @param a 目标数组* @return 转换后的字符串*/public static <T> String toString(T[] a){StringBuffer sb = new StringBuffer();sb.append("[");for (int i = 0; i < Array.getLength(a); i++) {if(sb.length() != 1){sb.append(",");}Object element = Array.get(a, i);sb.append(element);}sb.append("]");return sb.toString();}}

2.业务与逻辑分离的思想

需求:

用户选择获取数据的方式(本地数据、网络数据)

实现
版本01

版本01:if-else直接实现

public class Test01 {public static void main(String[] args) {Scanner scan = new Scanner(System.in);System.out.println("请选择获取数据的方式:");System.out.println("1-获取本地数据");System.out.println("2-获取网络数据");int num = scan.nextInt();if(num == 1){System.out.println("请填写需要拷贝文件的路径:");String path = scan.next();File file = new File(path);BufferedInputStream bis = null;BufferedOutputStream bos = null;try {bis = new BufferedInputStream(new FileInputStream(path));bos = new BufferedOutputStream(new FileOutputStream(file.getName()));byte[] bs = new byte[1024];int len;while((len=bis.read(bs)) != -1){bos.write(bs, 0, len);}} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} finally {if(bis != null){try {bis.close();} catch (IOException e) {e.printStackTrace();}}if(bos != null){try {bos.close();} catch (IOException e) {e.printStackTrace();}}}}else if(num == 2){//https://wx2.sinaimg.cn/mw690/e2438f6cly1hoo3qpm7vrj21111jk4mn.jpgSystem.out.println("请填写下载图片的网址:");String path = scan.next();try {//创建链接对象URL url = new URL(path);//获取连接对象HttpURLConnection connection = (HttpURLConnection) url.openConnection();//设置参数connection.setConnectTimeout(5000);//设置连接超时时间connection.setReadTimeout(5000);//设置读取数据超时时间connection.setDoInput(true);//设置是否允许使用输入流connection.setDoOutput(true);//设置是否允许使用输出流//获取响应状态码int code = connection.getResponseCode();if(code == HttpURLConnection.HTTP_OK){//文件名String fileName = path.substring(path.lastIndexOf("/")+1);BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileName));byte[] bs = new byte[1024];int len;while((len = bis.read(bs)) != -1){bos.write(bs, 0, len);}bis.close();bos.close();}else if(code == HttpURLConnection.HTTP_NOT_FOUND){System.out.println("页面未找到");}} catch (MalformedURLException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}scan.close();}
}
版本02

版本02:简单分离,优化if-else问题

优化:使用类、接口哪个更好?

注意:

如果就只是固定功能或者说DataSource仅是有抽象方法就用接口更好

如果需要添加新的功能用类更好

public class Test01 {public static void main(String[] args) {Scanner scan = new Scanner(System.in);System.out.println("请选择获取数据的方式:");System.out.println("1-获取本地数据");System.out.println("2-获取网络数据");int num = scan.nextInt();if(num == 1){LocalDataSource dataSource = new LocalDataSource();dataSource.getDataSource();}else if(num == 2){NetworkDataSource dataSource = new NetworkDataSource();dataSource.getDataSource();}scan.close();}
}

数据源

public abstract class DataSource {public abstract void getDataSource();}//获取本地资源的类
public class LocalDataSource extends DataSource{private Scanner scan;public LocalDataSource() {scan = new Scanner(System.in);}@Overridepublic void getDataSource() {System.out.println("请填写需要拷贝文件的路径:");String path = scan.next();File file = new File(path);BufferedInputStream bis = null;BufferedOutputStream bos = null;try {bis = new BufferedInputStream(new FileInputStream(path));bos = new BufferedOutputStream(new FileOutputStream(file.getName()));byte[] bs = new byte[1024];int len;while((len=bis.read(bs)) != -1){bos.write(bs, 0, len);}} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} finally {if(bis != null){try {bis.close();} catch (IOException e) {e.printStackTrace();}}if(bos != null){try {bos.close();} catch (IOException e) {e.printStackTrace();}}}}}//获取网络资源的类
public class NetworkDataSource extends DataSource{private Scanner scan;public NetworkDataSource() {scan = new Scanner(System.in);}@Overridepublic void getDataSource() {//https://wx2.sinaimg.cn/mw690/e2438f6cly1hoo3qpm7vrj21111jk4mn.jpgSystem.out.println("请填写下载图片的网址:");String path = scan.next();try {//创建链接对象URL url = new URL(path);//获取连接对象HttpURLConnection connection = (HttpURLConnection) url.openConnection();//设置参数connection.setConnectTimeout(5000);//设置连接超时时间connection.setReadTimeout(5000);//设置读取数据超时时间connection.setDoInput(true);//设置是否允许使用输入流connection.setDoOutput(true);//设置是否允许使用输出流//获取响应状态码int code = connection.getResponseCode();if(code == HttpURLConnection.HTTP_OK){//文件名String fileName = path.substring(path.lastIndexOf("/")+1);BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileName));byte[] bs = new byte[1024];int len;while((len = bis.read(bs)) != -1){bos.write(bs, 0, len);}bis.close();bos.close();}else if(code == HttpURLConnection.HTTP_NOT_FOUND){System.out.println("页面未找到");}} catch (MalformedURLException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}
}
版本03

版本03:在原有基础,新增功能

对菜单和数据源都在数据中心配合配置文件进行初始,可维护性更好

将菜单信息放在配置文件,再取出来存在一个集合里(ps:代码中的数据中心dataSource)
再打印查看展示

本地资源,网络资源路径放在配置文件
初始化数据源的循环获取对象,放在dataSource

添加其他功能,即新增功能,更改配置文件

public class Test01 {public static void main(String[] args) {Scanner scan = new Scanner(System.in);showMenu();int num = scan.nextInt();DataSource dataSource = getDataSourceObject(num);dataSource.getDataSource();scan.close();}public static void showMenu(){System.out.println("请选择获取数据的方式:");ArrayList<String> menulist = DataCenter.menuList;for (String element : menulist) {System.out.println(element);}}public static DataSource getDataSourceObject(int num){DataSource dataSource = DataCenter.dataSourceList.get(num-1);return dataSource;}
}

数据中心

//数据中心
public class DataCenter {public static final ArrayList<String> menuList;public static final ArrayList<DataSource> dataSourceList;//初始化菜单数据static{menuList = new ArrayList<>();Properties p = new Properties();try {p.load(DataCenter.class.getClassLoader().getResourceAsStream("menuConfig.properties"));} catch (IOException e) {e.printStackTrace();}String data = p.getProperty("data");String[] split = data.split(",");Collections.addAll(menuList, split);}//初始化数据源数据static{dataSourceList = new ArrayList<>();Properties p = new Properties();try {p.load(DataCenter.class.getClassLoader().getResourceAsStream("dataSourceConfig.properties"));} catch (IOException e) {e.printStackTrace();}String data = p.getProperty("data");String[] split = data.split(",");for (String classPath : split) {try {Class<?> clazz = Class.forName(classPath);DataSource dataSouce = (DataSource) clazz.newInstance();dataSourceList.add(dataSouce);} catch (ClassNotFoundException e) {e.printStackTrace();} catch (InstantiationException e) {e.printStackTrace();} catch (IllegalAccessException e) {e.printStackTrace();}		}}
}

配置文件

menuConfig.properties

注意:写进去不是中文显示为正常现象

data=1-\u83B7\u53D6\u672C\u5730\u6570\u636E,2-\u83B7\u53D6\u7F51\u7EDC\u6570\u636E,3-\u83B7\u53D6\u5176\u4ED6\u6570\u636E

dataSourceConfig.properties

data=com.qf.reflex02.LocalDataSource,com.qf.reflex02.NetworkDataSource,com.qf.reflex02.OtherDataSource

数据源

public abstract class DataSource {public abstract void getDataSource();}//获取本地资源的类
public class LocalDataSource extends DataSource{private Scanner scan;public LocalDataSource() {scan = new Scanner(System.in);}@Overridepublic void getDataSource() {System.out.println("请填写需要拷贝文件的路径:");String path = scan.next();File file = new File(path);BufferedInputStream bis = null;BufferedOutputStream bos = null;try {bis = new BufferedInputStream(new FileInputStream(path));bos = new BufferedOutputStream(new FileOutputStream(file.getName()));byte[] bs = new byte[1024];int len;while((len=bis.read(bs)) != -1){bos.write(bs, 0, len);}} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} finally {if(bis != null){try {bis.close();} catch (IOException e) {e.printStackTrace();}}if(bos != null){try {bos.close();} catch (IOException e) {e.printStackTrace();}}}}}//获取网络资源的类
public class NetworkDataSource extends DataSource{private Scanner scan;public NetworkDataSource() {scan = new Scanner(System.in);}@Overridepublic void getDataSource() {//https://wx2.sinaimg.cn/mw690/e2438f6cly1hoo3qpm7vrj21111jk4mn.jpgSystem.out.println("请填写下载图片的网址:");String path = scan.next();try {//创建链接对象URL url = new URL(path);//获取连接对象HttpURLConnection connection = (HttpURLConnection) url.openConnection();//设置参数connection.setConnectTimeout(5000);//设置连接超时时间connection.setReadTimeout(5000);//设置读取数据超时时间connection.setDoInput(true);//设置是否允许使用输入流connection.setDoOutput(true);//设置是否允许使用输出流//获取响应状态码int code = connection.getResponseCode();if(code == HttpURLConnection.HTTP_OK){//文件名String fileName = path.substring(path.lastIndexOf("/")+1);BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileName));byte[] bs = new byte[1024];int len;while((len = bis.read(bs)) != -1){bos.write(bs, 0, len);}bis.close();bos.close();}else if(code == HttpURLConnection.HTTP_NOT_FOUND){System.out.println("页面未找到");}} catch (MalformedURLException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}
}//新增功能的类
public class OtherDataSource extends DataSource{@Overridepublic void getDataSource() {System.out.println("获取其他数据");}}

3.操作注解

简单涉及注解开发,没有遵循注解规范就报错,当然这里处理是随便抛的异常

注意:这里为前面反射获取注解信息及实际运用做了补充

工具类里,利用反射,设置权限,获取注解,属性的数据拿到
数据字符串拼接用StringBuilder或者Strinngbuffer

//表
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TableInfo {String name();
}
//属性
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface FieldInfo {String name();String type();
}

学生类

添加注解

package com.qf.reflex03;@TableInfo(name="s_student")
public class Student {@FieldInfo(name="s_name",type="varchar")private String name;@FieldInfo(name="s_sex",type="varchar")private String sex;@FieldInfo(name="s_age",type="int")private int age;public Student() {}public Student(String name, String sex, int age) {this.name = name;this.sex = sex;this.age = age;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}@Overridepublic String toString() {return "Student [name=" + name + ", sex=" + sex + ", age=" + age + "]";}
}

工具类

public class DBUtil {public static String generateInsertSQL(Object obj){Class<? extends Object> clazz = obj.getClass();//获取表名TableInfo tableInfo = clazz.getAnnotation(TableInfo.class);if(tableInfo == null){throw new RuntimeException();}String tableName = tableInfo.name();StringBuffer names = new StringBuffer();StringBuffer values = new StringBuffer();//获取属性数据Field[] fields = clazz.getDeclaredFields();for (Field field : fields) {field.setAccessible(true);FieldInfo fieldInfo = field.getAnnotation(FieldInfo.class);String name = fieldInfo.name();String type = fieldInfo.type();if(names.length() != 0){names.append(",");}names.append(name);try {if(values.length() != 0){values.append(",");}Object fieldData = field.get(obj);if(type.equals("varchar")){values.append("'");}values.append(fieldData);if(type.equals("varchar")){values.append("'");}} catch (IllegalArgumentException e) {e.printStackTrace();} catch (IllegalAccessException e) {e.printStackTrace();}}String sql = "INSERT INTO " + tableName + "(" + names.toString() + ") VALUES(" + values.toString() + ");";return sql;}}

测试类

public class Test01 {public static void main(String[] args) {Student stu = new Student("奇男子", "男", 18);String sql = DBUtil.generateInsertSQL(stu);System.out.println(sql);//INSERT INTO s_student(s_name,s_sex,s_age) VALUES('奇男子','男',18);}
}

总结

1.反射案例 – 万能数组扩展
注意:
1.泛型的使用

2.反射案例 – 业务与逻辑分离的思想
注意:
1.理解思想
2.灵活使用配置文件
3.理解数据中心DataCenter

3.反射案例 – 操作注解
注意:
1.理解注解是可以给类、属性、方法提供额外信息

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/825846.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【史上最全】带你全方位了解containerd 的几种插件扩展模式

除了 snapshotter&#xff0c;containerd 的扩展机制你还了解哪些&#xff1f; 本文内容节选自 《containerd 原理剖析与实战》&#xff0c;本书正参加限时优惠内购&#xff0c;限时 69.9 元购买。 进入正题之前先看一下 containerd 的整体架构 1. containerd 架构 图 contain…

UE4_常见动画节点学习_Two Bone IK双骨骼IK

学习资料&#xff0c;仅供参考&#xff01; Two Bone IK 控制器将逆运动&#xff08;IK&#xff09;解算器应用于到如角色四肢等3关节链。 变量&#xff08; HandIKWeight &#xff09;被用于在角色的 hand_l 和 hand_r 控制器上驱动 关节目标位置&#xff08;Joint Target Lo…

Navicat连接postgresql时出现‘datlastsysoid does not exist‘报错的问题

连接报错 解决方案 解决方法1&#xff1a;升级navicat 解决方法2&#xff1a;降级pgsql 解决方法3&#xff1a;修改dll 使用3解决 实操演示 1、 打开 Navicat 安装目录&#xff0c;找到libcc.dll文件 2、备份libcc.dll文件&#xff0c;将其复制并粘贴或者修改副本为任何其他名…

【C++杂项】cin的详细用法

cin详细用法 1. cin简介2. cin的常用读取方法2.1 cin>>的用法2.2 cin.get的用法2.3 cin.getline的用法 3. cin清空输入缓冲区4. 其它方法4.1 getline()读取一行 1. cin简介 cin是C中的标准输入流对象&#xff0c;即istream类的对象。cin主要用于从标准输入读取数据&…

DNS服务器的管理与配置

目录 一、相关知识 域名空间 DNS服务器分类 域名解析过程 资源记录 二、安装DNS服务 安装bind软件包 DNS服务的启动与停止 配置主要名称服务器 主配置文件 从例子学起&#xff1a; &#xff08;1&#xff09;建立主配置文件named.conf &#xff08;2&#xff09;…

Windows10安装Docker Desktop(大妈看了都会)

目录 Windows10安装Docker Desktop&#xff08;大妈看了都会&#xff09; 1.前言 1.1 为什么要在Windows10上安装Docker 1.2 Docker Desktop介绍 2.下载Docker Desktop 3.启用Hyper-V以在 Windows 10上创建虚拟机 4.安装Docker Desktop 5.运行Docker Desktop 6.Docker…

阿里云图片处理之 缩放

文档 : https://help.aliyun.com/zh/oss/user-guide/resize-images-4?spma2c4g.11186623.0.0.61cd2759v4jkhX 需求 : 图片过大, 导致加载过慢, 需对图片进行压缩 <image :src"imgUrl ?x-oss-processimage/resize,h_700,m_lfit"></image>Ps : 题外话…

如何下载省,市,区县行政区Shp数据

摘要&#xff1a;一般非专业的GIS应用通常会用到省市等行政区区划边界空间数据做分析&#xff0c;本文简单介绍了如何在互联网上下载省&#xff0c;市&#xff0c;区县的shp格式空间边界数据&#xff0c;并介绍了一个好用的在线数据转换工具&#xff0c;并且开源。 目录 一、下…

深度 | 践行绿色健康可持续发展,这家企业提供了价值范本

文 | 螳螂观察 作者 | 余一 近段时间以来&#xff0c;小米SU7热度一直不减&#xff0c;在展露小米强大品牌号召力的同时&#xff0c;也侧面体现出了当前消费者对于新能源汽车的喜爱。 而消费者选择新能源汽车时&#xff0c;环保因素也起到了至关重要的作用。像前几日&#x…

数据结构-上三角矩阵存储方式[0知识掌握]

目标&#xff1a;看完本文章你将会了解上三角矩阵的存储方式以及矩阵中数据的位置索引号如何求 难点&#xff1a;上三角矩阵的公式推导&#xff0c;上三角任意位置对应的存储位置。 一、准备知识 1.求和公式 前n项和&#xff1a;Sn n(a1an)/2 公差&#xff1a;d后项-前项…

【JavaEE多线程】线程安全、锁机制及线程间通信

目录 线程安全线程安全问题的原因 synchronized 关键字-监视器锁monitor locksynchronized的特性互斥刷新内存可重入 synchronized使用范例 volatilevolatile能保证内存可见性volatile不保证原子性synchronized 也能保证内存可见性 wait 和 notifywait()方法notify()方法notify…

拖拽式工作流有哪几个优势?

在信息技术迅猛发展的今天&#xff0c;如何助力中小型企业在数字化转型的过程中平稳过渡&#xff1f;又是如何让中小型企业摆脱数据孤岛、成本投入高等各种瓶颈和难题&#xff1f;低代码技术平台是近些年较为理想的平台产品&#xff0c;其中拖拽式工作流优势特点突出&#xff0…

地埋电缆故障检测方法有哪些?地埋电缆故障检测费用是多少?

地埋电缆故障检测方法主要涵盖脉冲反射法、桥接法、高压闪络法和声波定位法等多种方法。选择适当的方法取决于故障类型、电缆类型和实际现场条件。至于地埋电缆故障检测费用则受到多个因素的影响&#xff0c;包括故障类型、检测方法的复杂性、检测设备的先进程度以及所处地区的…

从零开始搭建社交圈子系统:充实人脉的最佳路径

线上交友圈&#xff1a;拓展社交网络的新时代 线上交友圈是社交网络的新引擎&#xff0c;提供了更广泛的社交机会&#xff0c;注重共同兴趣的连接&#xff0c;强调多样性的社交形式&#xff0c;更真实地展示自己&#xff0c;让朋友更全面地了解我们的生活状态。虽然虚拟交往存在…

SD-WAN解决电商企业海外业务网络难题

全球化背景下&#xff0c;众多国内企业都涉及到海外贸易业务&#xff0c;尤其是出海电商得到蓬勃发展。企业做出海电商&#xff0c;需要访问国外网页、社交平台&#xff0c;如亚马逊、TikTok、Facebook、YouTube等与客户沟通互动&#xff0c;SD-WAN的发展正好为解决国际网络访问…

14 Php学习:表单

表单 PHP 表单是用于收集用户输入的工具&#xff0c;通常用于网站开发。PHP 可以与 HTML 表单一起使用&#xff0c;用于处理用户提交的数据。通过 PHP 表单&#xff0c;您可以创建各种类型的表单&#xff0c;包括文本输入框、复选框、下拉菜单等&#xff0c;以便用户可以填写和…

主存储器与CPU之间的连接(会画图)

位扩展 字扩展 由于只有A13&#xff0c; A14 连到了译码器上&#xff0c;以、因此该译码器是一个 2/4 译码器&#xff0c;对应的选片有四种。选中第一个选片&#xff0c;就是把译码器“0口置0&#xff0c; 1~3口置1”&#xff0c;因为CS有非号&#xff0c;因此&#xff0c;低电…

【C++】string的使用

目录 1、为什么学习string类&#xff1f; 2、标准库中的string类 2.1 string类 2.2 string类的常见接口声明 2.2.1 string类的常见构造 ​编辑 2.2.2 string类对象的访问及遍历操作 2.2.3 string类对象的容量操作 2.2.4 string类对象的修改操作 ​编辑 1、为什么学习s…

excel中vlookup查找值必须在table_array的第一列,有其他办法吗有XLOOKUP

vlookup查找值必须在table_array的第一列&#xff0c;有其他办法吗&#xff1f;有XLOOKUP。 vlookup 查找如下&#xff0c;查找值必须在table_array的第一列 如果下面&#xff0c;编码和名称交换位置&#xff0c;就不能使用vlookup查找了。 XLOOKUP 查找如下

Linux:进程调度

Linux&#xff1a;进程调度 进程优先级查看优先级调整优先级 Linux 2.6 内核进程调度队列 进程优先级 查看优先级 在Linux中&#xff0c;进程是有优先级的&#xff0c;我们可以通过指令ps -la来查看&#xff1a; 其中PRI表示priority优先级&#xff0c;在Linux中&#xff0c;…