Your code is correct, although I would also recommend using iterators:
import java.util.ArrayList; import java.util.Arrays; public class Main { public static void main(String[] args) throws Exception { ArrayList<String> contain = new ArrayList<String>(Arrays.asList("HPDH-1,001, Check-out date: 7/7/7", "JTI-1,001, Check-out date: 7/7/7")); String code = "JTI";
Output:
JTI-1.001, Check-out Date: 7/7/7
JTI-1.001, Check-out Date: 7/7/7
If this result is not what you want, add more information.
source share