MikeMirzayanov's blog

By MikeMirzayanov, 8 years ago, translation, In English

About two days ago Java 8 has been released! It is a great update with many interesting improvements and features. If you do not plan to use new language syntax, probably Java 8 will please you with performance improvements.

I've added Java 8 with options like for other versions of Java: java.exe -Xmx512M -Xss64M -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US -jar %s.

Right now, Java 8 supported in testing mode. Let's try it together on problemset problems.

You may see new features in this code — it sorts lines in non-increasing lexicographical order:

import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            List<String> lines = new ArrayList<>();
            while (scanner.hasNextLine()) {
                lines.add(scanner.nextLine());
            }
            lines.stream().sorted((a, b) -> b.compareTo(a)).forEach(System.out::println);
        }
    }
}
 
 
 
 
  • Vote: I like it
  • +77
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it -53 Vote: I do not like it

Thanks, BTW Why don't you add C++11 in languages?

  • »
    »
    8 years ago, # ^ |
      Vote: I like it +30 Vote: I do not like it

    C++0x is already added

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it -25 Vote: I do not like it

      What about Objective-C? Is it too difficult to configure clang or something else?

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

http://codeforces.com/contest/404/submission/6174479 In the above submission I used Arrays.setAll(lists, ArrayList::new), and it caused a MLE. But it was accepted once I replaced setAll with a loop.

  • »
    »
    8 years ago, # ^ |
      Vote: I like it +29 Vote: I do not like it

    because Arrays.setAll(lists, ArrayList::new) equals to

    for (int i = 0; i < n; ++i) lists[i] = new ArrayList<>(i);
    

    Correct call:

    Arrays.setAll(lists, i -> new ArrayList<>());
    
»
8 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Which new features of JAVA 8 are very useful for our sport programming?

  • »
    »
    8 years ago, # ^ |
    Rev. 6   Vote: I like it +15 Vote: I do not like it

    At Java 8 there is new implementation of HashSet (HashMap) for resisting of attack on they buckets. In some cases it mutate to "table of trees" and from this state it can mutate to "table of linked lists" back :-)

    New string-hashing implementation, improved collision performance for string-valued containers.