Java 10 : 'var' variable example

'var' keyword - "var" variable introduced in Java 10 to declared any type of datatype.

Example:

var message= "hello";
var size = 10;
var array = new String[]{"1","2","3"};

for(var i=0;i<10;i++){
}


var in collection:

var map = getMap();

public Map<String,String> getMap(){
Map<String,String> m=new HashMap<>();
m.put("1","1");
return m;
}

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation