Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Collections;;
- import java.util.Map;
- import java.util.List;
- import java.util.Arrays;
- import java.util.stream.Collectors;
- // Collections_Framework
- class /*Main*/Collections_Framework {
- //
- public static void main(String[] args) {
- //
- Map<String, Integer> s_M = Collections.singletonMap("key_1", 1);
- //
- System.out.println("hello world");
- System.out.println(s_M);
- s_M.forEach((k, v) -> {
- System.out.println("k:" + k);
- System.out.println("v:" + v);
- }
- );
- System.out.println(s_M.entrySet());
- System.out.println(s_M.entrySet().toArray()[0]);
- //
- List<Character> l_C = Collections.nCopies(9, '#');
- //
- System.out.println(l_C);
- // fromIndex, inclusive, and toIndex, exclusive
- List<Character> sub_L_3 = l_C.subList(0, 3);
- //
- System.out.println(sub_L_3);
- //CharSequence
- char[] chars = new char[9];
- System.out.println(
- sub_L_3
- .stream()
- .map(i -> i.toString())
- .collect(Collectors.joining(""))
- );
- System.out.println(sub_L_3.listIterator(0).next());
- /// ### .mkString analog ### ///
- List<Integer> numbers = Arrays.asList(1, 2, 3, 4);
- String commaSeparatedNumbers = numbers
- .stream()
- .map(i -> i.toString())
- .collect(Collectors.joining(", "));
- //
- System.out.println(commaSeparatedNumbers);
- //
- }
- //
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement