String str = "1,2,3,4,5"; ListintList = ConverterUtil.toList(str, Integer.class); System.out.println(intList); // [1, 2, 3, 4, 5]
Employee emp1 = new Employee("John", "Doe", "[email protected]"); Employee emp2 = new Employee("Jane", "Doe", "[email protected]"); ListIn this example, we are converting a list of Employee objects into another list of Employee objects using the toList() method. The ConverterUtil class is part of the org.apache.axis2.databinding.utils package from the Apache Axis2 framework.empList = ConverterUtil.toList(Arrays.asList(emp1, emp2), Employee.class); System.out.println(empList); // [Employee [firstName=John, lastName=Doe, [email protected]], Employee [firstName=Jane, lastName=Doe, [email protected]]]