Browsing Category:Java

Java, Programming

How To Remove an Element From An Array Java 8

String[] array = new String[]{ "1", "2", "3" };String[] output1 = Arrays.stream(array).skip(1).toArray(String[]::new);String[] output2 = Arrays.stream(array).limit(2).toArray(String[]::new);String[] output3 = Arrays.stream(array).skip(1).limit(1).toArray(String[]::new);System.out.println(String.join(", ", output1));System.out.println(String.join(", ", output2));System.out.println(String.join(", ", output3));Output:2,...
Continue reading
Share
Java, Programming

How To Print an ArrayList In Java 8

List of StringList<String> list = Arrays.asList("1", "2", "3");System.out.println(String.join(", ", list));Output:1, 2, 3 List of ObjectList<Object> list = Arrays.asList(new Object(), new Object(), new Object());System.out.println(Arrays.toString(list.toArray()));Output:[java.lang.Object@1b6d3586, java.lang.Object@4554617c, java.lang.Object@74a14482] 
Continue reading
Share