当前位置:网站首页>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
边栏推荐
- Network type
- Add of cmake_ dependencies
- How to use the directory classification function of the new version of easycvr (v2.5.0)?
- CANopen communication - PDO and SDO
- Some ideas and skills suitable for pinduoduo small business accessories
- Hardware knowledge 2 -- Protocol class (based on Baiwen hardware operation Daquan video tutorial)
- Notes - record the solution to the failure of @refreshscope dynamic refresh configuration
- Phantom core is about to close? Is there a future for digital collections?
- How QT counts the frequency of letters in a string
- jenkins多任务并发构建
猜你喜欢

Vessel Segmentation in Retinal Image Based on Retina-GAN

Basic knowledge of mathematical vector

Hcip day 4 notes

Study and use of burpsuite plug-in

Install SSL Certificate in Litespeed web server

Hcip day 12 notes

选址与路径规划问题(Lingo,Matlab实现)

Spark partition operators partitionby, coalesce, repartition

Notes - record the solution to the failure of @refreshscope dynamic refresh configuration

jenkins多任務並發構建
随机推荐
hdu-7141 Ball (bitset)
Non boost ASIO notes: UDP UART socketcan multicast UDS
Excel simple macro
xxl-job使用注意事项
Using tessellation in unity
jenkins多任務並發構建
Matlab绘制双坐标图(全网最简单)
医院综合布线
php7 垃圾回收机制详解
Simple Gan instance code
OSPF (sixth day notes)
Thread pool interview
Troisième semaine d'été
1000 okaleido tiger launched binance NFT, triggering a rush to buy
Try to run this command from the system terminal Make sure that you use the correct
Precautions for using XXL job
Improvement of DB file sequential read caused by insert
MySQL Basics (operators, sorting and paging, multi table queries, functions)
How to finally generate a file from saveastextfile in spark
[pumpkin Book ml] (task3) decision tree (updating)