Insert a non-existent value into a Map in Java 8
February 21, 2015 Leave a comment
Consider the following Employee class:
public class Employee
{
private UUID id;
private String name;
private int age;
public Employee(UUID id, String name, int age)
{
this.id = id;
this.name = name;
this.age = age;
}
public UUID getId()
{
return id;
}
public void setId(UUID id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
}
Let’s put some Employee objects into a hash map: