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++){
}
public Map<String,String> getMap(){
Map<String,String> m=new HashMap<>();
m.put("1","1");
return m;
}
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
Post a Comment