split() method : Specify character ( strand ) Or regular to split a string , The result is returned as an array of strings ;

Several codes and results are given :
1, The result is 0
public class TestSpit { public static void main(String[] args) { String str =
"@"; System.out.println(str.split("@" ).length); } } "E:\JAVA\IntelliJ IDEA
2019.3.2\jbr\bin\java.exe" "-javaagent:E:\JAVA\IntelliJ IDEA
2019.3.2\lib\idea_rt.jar=50176:E:\JAVA\IntelliJ IDEA 2019.3.2\bin" -Dfile.
encoding=UTF-8 -classpath E:\JAVA\project\day06-code\out\production\day06-code
com.lg.demo11.TestSpit 0 Process finished with exit code 0
2, The result is 1
public class TestSpit { public static void main(String[] args) { String str =
""; System.out.println(str.split("@" ).length); } }
The original string does not contain @
"E:\JAVA\IntelliJ IDEA 2019.3.2\jbr\bin\java.exe" "-javaagent:E:\JAVA\IntelliJ
IDEA 2019.3.2\lib\idea_rt.jar=50461:E:\JAVA\IntelliJ IDEA 2019.3.2\bin" -Dfile.
encoding=UTF-8 -classpath E:\JAVA\project\day06-code\out\production\day06-code
com.lg.demo11.TestSpit 1 Process finished with exit code 0
3, The result is 2
public class TestSpit { public static void main(String[] args) { String str =
"123@123"; System.out.println(str.split("@" ).length); } } "E:\JAVA\IntelliJ
IDEA 2019.3.2\jbr\bin\java.exe" "-javaagent:E:\JAVA\IntelliJ IDEA
2019.3.2\lib\idea_rt.jar=50507:E:\JAVA\IntelliJ IDEA 2019.3.2\bin" -Dfile.
encoding=UTF-8 -classpath E:\JAVA\project\day06-code\out\production\day06-code
com.lg.demo11.TestSpit 2 Process finished with exit code 0
4, The result is 3
public class TestSpit { public static void main(String[] args) { String str =
"123@123@123"; System.out.println(str.split("@" ).length); } }
"E:\JAVA\IntelliJ IDEA 2019.3.2\jbr\bin\java.exe" "-javaagent:E:\JAVA\IntelliJ
IDEA 2019.3.2\lib\idea_rt.jar=50544:E:\JAVA\IntelliJ IDEA 2019.3.2\bin" -Dfile.
encoding=UTF-8 -classpath E:\JAVA\project\day06-code\out\production\day06-code
com.lg.demo11.TestSpit 3 Process finished with exit code 0

Technology
©2019-2020 Toolsou All rights reserved,
First knowledge python Skills summary GDOI2019 travels c Linguistic 5 Three common sorting methods Python Basic knowledge and notes " Cephalosporin wine Say go and go "? DANGER ! Don't drink alcohol when taking these drugs Thorough explanation from Zhongtai vue The component page height is adaptive according to the screen size Classical algorithm - recursion ( The case of raw rabbit ) Big data tells you , How tired are Chinese women about keras use fit_generator Encountered in StopIteration