1

It's my first time to use the .split() method in JAVA to split string. Unfortunately,what I've been given is to put "||" as the split regex. But it didn't work. Does anyone know why? .split() works just fine when I use "//" or "/" or "--". I'm just curious why "||" provides different result.

Simulation:

String a = abc||acs||bbb

a.split("||") will provide the following result:
a
b
c
|
|
a
c
s
|
|
b
b
b
-END OF RESULT-

Does anyone out here knows why? It works just fine with "//" or anything else but not "||". Thanks!

SORRY! THE ANSWER IS HERE

Community
  • 1
  • 1
Nico
  • 323
  • 2
  • 5
  • 17

0 Answers0