DEV Community

Discussion on: Python or Java? Which is better to learn to code?

Collapse
 
olegthelilfix profile image
Oleg Aleksandrov

Thanks for your post, but java 8+ can be more compact
For ex:
String operation:

        String test = "compare Java with Python";
        Arrays.asList(test.split(" ")).forEach(System.out::println);

About maps

        Map<String, String> map = new HashMap<String, String>() {{
            put("1", "2");
            put("2", "3");
        }};

        map.forEach((key, value) -> System.out.println("key=" + key + " value="+ value));

And other examples I think can be made shorter.

Collapse
 
javinpaul profile image
javinpaul

Indeed, Java 8 makes Java code more concise.