Reputation: 517
Reading a Java project on GitHub, I found a code syntax that I have never seen before and I would some explanation, please. Here is the code:
Book book = new BookBuilder() {
{
description("blabla");
author("blabla");
title("blabla");
isbn("123456789");
category(category);
}
}.build();
BookBuilder
seems to be a standard java class and each of methods called (description, author...) return a BookBuilder
object.
My question is, what does the syntax book = new BookBuilder() {{ ... }}
means?
Upvotes: 0
Views: 33