上QQ阅读APP看书,第一时间看更新
Local variable type inference
Starting with Java 10, declaring local variables has been simplified. Developers no longer have to include manifest declarations of local variable types. This is accomplished using the new var identifier, as shown in this example:
var myList = new ArrayList<String>();
Using the preceding code, ArrayList<String> is inferred, so we no longer need to use ArrayList<String> myList = new ArrayList<String>();.
Local variable type inference is covered in Chapter 3, Java 11 Fundamentals.