Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2012may11 Language: Java Q. Why is String.split() not giving me empty strings?String subject = ":"; String a = subject.split(":");Gives me an a.length == 0 but I expect 2. A. Regular split (helpfully) deletes trailing empty strings. So use the other form of split:String subject = ":"; String a = subject.split(":", -1);
Add a commentSign in to add a comment