Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Ashish Choudhary yrashish

🏠
Working from home
View GitHub Profile
View dockerPullConsole.log
docker pull hiashish/spring-boot-jib-image
Using default tag: latest
latest: Pulling from hiashish/spring-boot-jib-image
5749e56bea71: Already exists
a3e61620654b: Already exists
e708be98c58f: Already exists
71f0443d2e95: Already exists
febab311d432: Already exists
6508f436f385: Already exists
c5e22041fc97: Already exists
View Allowed.java
var str = new String("Hello");
var list = new ArrayList<String>();
var integerList = List.of(1,2,3,4);
for (var data :integerList) {
System.out.println(data);
}
for (var i = 1; i <= integerList.size(); i++) {
System.out.println(i);
}
var path = Paths.get("/src/main/resources/app.log");
View ExampleNotVar.java
List<Employee> employees = Arrays.asList(new Employee(1, "Ashish", 28, 10000)
, new Employee(2, "Ajay", 29, 1000)
, new Employee(3, "Abhishek", 29, 10000));
Map<Integer, String> map = employees
.stream()
.collect(Collectors.toMap(Employee::getId, Employee::getName));
Map<Long, List<Employee>> listMap = employees
.stream()
.collect(Collectors.groupingBy(Employee::getSalary));
View NotAllowed.java
//Cannot infer type: 'var' on variable without initializer
var x;
//Cannot infer type: lambda expression requires an explicit target type
var f = () -> {};
//Cannot infer type: variable initializer is 'null'
var g = null;
//Array initializer is not allowed here
var k = {1, 2};
View ExampleVar.java
var employees = Arrays.asList(new Employee(1, "Ashish", 28, 10000)
, new Employee(2, "Ajay", 29, 1000)
, new Employee(3, "Abhishek", 29, 10000));
var employeeMap = employees.stream()
.collect(Collectors.toMap(Employee::getId, Employee::getName));
var groupedMap = employees.stream()
.collect(Collectors.groupingBy(Employee::getSalary));