当前位置:网站首页>The difference between.Split (",", -1) and.Split (",")
The difference between.Split (",", -1) and.Split (",")
2022-07-24 01:51:00 【Lion boy】
List of articles
- There is only one difference
- 1、 When the last bit of the string has a value , There is no difference between the two
- 2、 When the last bit of the string perhaps N When bit is a separator , The former will not continue to segment , The latter continues to segment . That is, the former is not reserved null value , The latter is reserved .
- give an example :
- Be careful , Empty strings in the middle are not ignored
- Be careful , Need to escape (\\) The characters of Yes :" | " ^ " * " . " + "
- Be careful : " , " There is no need to escape
There is only one difference
1、 When the last bit of the string has a value , There is no difference between the two
2、 When the last bit of the string perhaps N When bit is a separator , The former will not continue to segment , The latter continues to segment . That is, the former is not reserved null value , The latter is reserved .
give an example :
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
int sum = 0;
String s = sc.nextLine();
String[] str = s.split("\\.",-1);
for(int i=0; i<str.length; i++){
System.out.println(str[i]);
}
}
}
}
Input :
Henan .. hebei .
If it is split(“\.”,-1), The output :
If yes, if yes split(“\.”), Output :

Be careful , Empty strings in the middle are not ignored
Be careful , Need to escape (\) The characters of Yes :" | " ^ " * " . " + "
Be careful : " , " There is no need to escape
边栏推荐
- win11之缺点
- 机房建设资料
- OSPF (fifth day notes)
- How to finally generate a file from saveastextfile in spark
- Cartland number---
- Exchange 2013 SSL证书安装文档
- How to solve the problem that the device video cannot be played due to the missing CGO playback callback parameters of easycvr platform?
- Digicert code signing certificate
- How to install, download and use the latest version of IDM software
- MGRE GRE OSPF process in hcip
猜你喜欢

145-keep-alive的初步使用

Install SSL Certificate in Litespeed web server

Database design

On the possibility and limitation of defi in the metauniverse
![[bdsec CTF 2022] partial WP](/img/00/25c1953a324fbf04e3baf592079978.png)
[bdsec CTF 2022] partial WP
深入理解微信小程序的底层框架(二)组件系统、Exparser

Hcip second day notes

Upload files to flash file system through Arduino IDE

浅谈元宇宙中DeFi的可能性和局限性

Notes - record a dynamic datasource please check the setting of primary problem solving
随机推荐
How QT counts the frequency of letters in a string
Jenkins multitask concurrent construction
机房建设资料
Notes - record a dynamic datasource please check the setting of primary problem solving
[code case] website confession wall & to do list (including complete source code)
解决script标签写在元素节点前面无法获取元素节点的问题
The third week of summer vacation
代码阅读方法与最佳实践
Database security and data integrity
jenkins多任务并发构建
Hcip third day notes
Copying readable paths is not easy
Install go environment under Kali
Hcip day 5 notes
Review of HCIA
jenkins多任務並發構建
[C language operation of linked list (initialization, establishment, length calculation, addition, deletion, and output of linked list)]
Local empowerment learning
Hcip seventh day notes
Some ideas and skills suitable for pinduoduo small business accessories