Sunday 16 June 2013

Get last split index in java

Use (length - 1) when the size of the Array can change.You get last String :-


public class Splits {

public static void main(String[] args) {

String[] name = "com-Kumar-java".split("-"); // pass your expression
String splitName = name[name.length - 1];

System.out.println(splitName);

}

}

No comments:

Post a Comment