[Solved] typical operations on stored string in java


but can that iterator be converted to char array ?

Yes Iterator#next() will give you string (because List has generic type String) that can be used to perform any kind of string operation. See the code below put it in main method and run.

    String[] str = {"Sam", "Mohit", "Laksh", "Nitesh"};
    List<String> list = new ArrayList<String>();
    for(int i=0;i<str.length;i++)
    {
       list.add(str[i]);
    }

    Iterator<String> iter = list.iterator();
    while(iter.hasNext()){
        //here apply some condition to get your specific string object
        char[] chars = iter.next().toCharArray();
        System.out.println(chars);
    }

2

solved typical operations on stored string in java