The object being replaced is returned from the set()
method.
import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] a) { List<String> list = Arrays.asList(new String[] { "CSS", "HTML", "Java", "Javascript" }); //from www .ja v a2 s . c om System.out.println(list); String replaced = list.set(2, "demo 2 s.com"); System.out.println("replaced:"+replaced); System.out.println(list); } }