当前位置:网站首页>Small knowledge of common classes
Small knowledge of common classes
2022-07-25 10:16:00 【Look at the bugs】
Boxing and UnBoxing
Boxing turns basic types into reference types
Unpacking changes the reference type to the basic type
int age=30;
// Automatic boxing
Integer integer4=age;
// Automatic dismantling
int age2 =integer4;
Basic type and string conversion
//1, The basic type is converted to a string
int n1=10;
String n2= n1+"";
// Use Integer Medium toString() Method
String s2=Integer.toString(n1);
//toString Overload method of n1 With 16 Hexadecimal said
String s3=Integer.toString(n1,16);
//2, String to base type
String s1="yan";
// Use integer2.parseInt() Method put int The type changes to String type
int n3=integer2.parseInt(s1);
//boolean The string form is changed to the basic type :"true"-->true, Not true-->false
String str2="true";
boolean bl=Boolean.parseBoolean(str2);
== and equals
== When comparing two basic types , Compare values
The comparison is that the reference type is , The comparison is the address
equals stay Object Class compares addresses
String Class overridden equals Method , stay String Next equals Compare values
Integer buffer
//Integer The number stored in the buffer is -128 To 127 The array between is stored in the heap
// Recreate storage space beyond the scope
Integer integer1=Integer.valueOf(100);
Integer integer2=Integer.valueOf(100);
System.out.println(integer1==integer2);
//true
Integer integer6=new Integer(200);
Integer integer7=new Integer(200);
System.out.println(integer6==integer7);
//false
String Method
String content =" kankanshijie ";
System.out.println(content.length()); // Returns the length of the string
System.out.println(content.charAt(0)); // Get the current character according to the subscript
System.out.println(content.contains("iji")); // Determine if the string contains "" String inside
System.out.println(Arrays.toString(content.toCharArray()));
//content.toCharArray() The address of the current string is printed
//Arrays.toString Print the string of the current address
System.out.println(content.trim()); // Remove the space before and after the string
System.out.println(content.toUpperCase()); // Become capital
System.out.println(content.toLowerCase());// Become lowercase
System.out.println(content.replace("kank","wod"));
// Replace the specified string with the desired string
System.out.println(Arrays.toString(content.split("ka")));
// Split string
String say="java is the best programing ,My Language";
String []arr=say.split("[, ]+"); // Inside the brackets is the judgment of what to split. Here are spaces and commas
System.out.println(arr.length); // Print array length
for(String string:arr){
System.out.println(string); // Print the string in the array
}
// Compare the position of two strings in the table and subtract , From the first , If the same, compare the next
// If the two preceding characters are the same , Just compare the length of two strings
// Can be used for sorting
String s1="abc";
String s2="xyz";
System.out.println(s1.compareTo(s2));
边栏推荐
猜你喜欢

VSCode Latex Workshop 设置 XeLatex 编译

ROS distributed operation -- launch file starts nodes on multiple machines

静态路由的配置(以华为eNSP为例)

UE4 外部打开exe文件

拷贝过来老的项目变成web项目
![腾讯云之错误[100007] this env is not enable anonymous login](/img/a2/a209a0d94e3fbf607242c28d87e2dd.png)
腾讯云之错误[100007] this env is not enable anonymous login

@Import, conditional and @importresource annotations

message from server: “Host ‘xxx.xxx.xxx.xxx‘ is not allowed to connect to this MySQL server“

Attention is all you need 论文精读笔记 Transformer
![严重 [main] org.apache.catalina.util.LifecycleBase.handleSubClassException 初始化组件](/img/39/6f6760e80acec0b02028ea2ed1a5b1.png)
严重 [main] org.apache.catalina.util.LifecycleBase.handleSubClassException 初始化组件
随机推荐
记录一些JS工具函数
Yarn quick reference manual
Nodejs initial experience
Wechat applet jumps to other applets
Basic knapsack problem
几个常用的网络诊断命令
Es6详解
Salt FAQs
vscode插件开发
链表相关(设计链表及环链表问题)
Round to the nearest
第五阶段第一周
复现 SSL_Anti-spoofing, 使用 wav2vec 2.0 和数据增强的自动说话人认证的欺骗攻击与深度伪造检测
车辆属性最近一次入库时间初始化生成sql脚本文件
UE4 快速找到打包失败的原因
[nearly 10000 words dry goods] don't let your resume don't match your talent -- teach you to make the most suitable resume by hand
复现 ASVspoof 2021 baseline RawNet2
VSCode Latex Workshop 设置 XeLatex 编译
The way of code neatness -- hit the pain point directly
字典树的使用