Roughly try Java 9

Prepare Docker appropriately.

FROM java:9
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
RUN javac Main.java
CMD ["java", "Main"]

It seems that takeWhile has been newly introduced. It's been a while since I touched Java, but it's interesting because it's different.

import java.util.stream.Stream;

public class Main {
  static public void main(String[] args) {
    Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
      .takeWhile(i -> i < 5)
      .forEach(System.out::println);
  }
}

I will do it.

$ docker build -t my-java-app .
$ docker run -it --rm --name my-running-app my-java-app
1
2
3
4

Sounds good.

I will also try jshell.

$ docker run -it my-java-app jshell

スクリーンショット 2017-10-26 05.14.33.png

It will be complemented and you can try it right away. It is still convenient to have a REPL.

Recommended Posts

Roughly try Java 9
Try Java 8 Stream
Try Java return value
Try using RocksDB in Java
Try scraping using java [Notes]
Try calling JavaScript in Java
Try functional type in Java! ①
Java
Java
Try implementing Android Hilt in Java
Try implementing GraphQL server in Java
Try running Selenuim 3.141.59 in eclipse (java)
Try an If expression in Java
Try to extract java public method
Try bidirectional communication with gRPC Java
Try running AWS X-Ray in Java
Try using IBM Java method tracing
Try Eclipse 4.7 Oxygen New 30+ / Java 10 var!
Try using Hyperledger Iroha's Java SDK
[Java] Where did you try using java?
Interface Try to make Java problem TypeScript 7-3
Java learning (0)
Java: Try implementing your own comma-separated formatter
Studying Java ―― 3
[Java] array
Try using Java framework Nablarch [Web application]
Java protected
[Java] Annotation
[Java] Module
Java array
Studying Java ―― 9
Java scratch scratch
Java tips, tips
Java methods
Java method
java (constructor)
Java array
[Java] ArrayDeque
Try to solve Project Euler in Java
java (override)
java (method)
Java string
java (array)
Java serialization
java beginner 4
JAVA paid
Studying Java ―― 4
Java (set)
java shellsort
[Java] compareTo
Studying Java -5
Try using the Stream API in Java
java reflexes
java (interface)
Java memorandum
☾ Java / Collection
Java array
Studying Java ―― 1
Try Mockito
[Java] Polymorphism
Studying Java # 0