Strictly speaking, I'm not sure whether this conversion is possible in Java, since you don't have both references and values of objects in Java - all objects are references (which are passed by value).
However, one can consider this similar to the following example:
"Value":
class Order
{
private int orderNum;
private Customer customer;
Order(int orderNum, String customerString)
{
this.orderNum = orderNum;
this.customer = new Customer(customerString);
}
}
// elsewhere:
Order order1 = new Order(1, "I am a customer");
Order order2 = new Order(2, "I am a customer");
Order order3 = new Order(3, "I am a customer");
Order order4 = new Order(4, "I am a customer");
Here each Order has it's own Customer object, even when all or most of those Customer objects are the same.
The above is, of course, just an example. Passing all parameters of another object into a constructor is not good design.
Reference:
class Order
{
private int orderNum;
private Customer customer;
Order(int orderNum, Customer customer)
{
this.orderNum = orderNum;
this.customer = customer;
}
}
Customer customer = new Customer("I am a customer");
Order order1 = new Order(1, customer);
Order order2 = new Order(2, customer);
Order order3 = new Order(3, customer);
Order order4 = new Order(4, customer);
Here we can have a single Customer for many Orders (if we want).