Answer the question
In order to leave comments, you need to log in
What are double curly braces in code?
Here is a piece of code, its essence is not important.
public List<SelectItem> filterOptions = new ArrayList<SelectItem>() {{
add(new SelectItem("Van"));
add(new SelectItem("Bus"));
add(new SelectItem("Compact"));
add(new SelectItem("Semi-Truck"));
add(new SelectItem("Pickup"));
}};
Answer the question
In order to leave comments, you need to log in
It is better to write it down so that it is clearer.
public List<SelectItem> filterOptions = new ArrayList<SelectItem>() {
// anonymous constructor()
{
add(new SelectItem("Van"));
add(new SelectItem("Bus"));
add(new SelectItem("Compact"));
add(new SelectItem("Semi-Truck"));
add(new SelectItem("Pickup"));
}
};
Apparently - the initialization block - https://habrahabr.ru/post/133237/ the first section.
PS I'm by no means an expert on java.
Thanks for enlightening me. How many more subtleties. any...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question