Splitting a String and using the second part only in java

I have a list of string like this:

private List<String> repositoryTitle;

this contains 3 values:


I want a list which contains these 3 values:

test, brokencrystals, petclinic

How to achieve this result dynamically?

>Solution :

Split them, and take the element at index 1.

   .map(str -> str.split("/")[1])

It will throw an exception if they don’t contain a slash, so you might want to filter them first.

Leave a Reply