Java 9 이하에서는 변수를 정의할 때 타입을 명시적으로 선언해야 했었다.



Java 10 에서는 var 키워드를 사용해서 타입 선언 없이 변수를 선언할 수 있다.



premitive type 뿐만 아니라 ArrayList<String> 타입도 var 키워드로 선언할 수 있다.



하지만 컴파일 에러가 발생하는 경우도 있다.

 

 

 

Java 10 Local Variable Type Inference

https://developer.oracle.com/java/jdk-10-local-variable-type-inference.html

 

Java 10 Local Variable Type Inference

Java 10 introduced a new shiny language feature called local variable type inference. Sounds fancy! What is it? Let’s work through two situations where Java makes things a little difficult for us as a Java developer. Context: Boilerplate and code readabi

developer.oracle.com

 

JEP 286: Local-Variable Type Inference

http://openjdk.java.net/jeps/286

 

JEP 286: Local-Variable Type Inference

JEP 286: Local-Variable Type Inference Summary Enhance the Java Language to extend type inference to declarations of local variables with initializers. Goals We seek to improve the developer experience by reducing the ceremony associated with writing Java

openjdk.java.net

 

 

 

 

+ Recent posts