Why do Java array declarations use curly brackets?

Evan picture Evan · Mar 14, 2011 · Viewed 10.7k times · Source

I would like to know why Java array declarations use curly brackets as opposed to the standard parenthesis. As illustrated here. I imagine this may take further understanding of curly brackets in general, but this specifically is on my agenda right now.

Object[] tableHeaders = {"Cars","Trucks","Tacos"};

This is correct, as opposed to.

Object[] tableHeaders = ("Cars","Trucks","Tacos");

Answer

Eric picture Eric · Mar 14, 2011

Curly brackets usually denotes sets and ensembles while parenthesis usually denotes parameters in C-like languages.

A long time ago, people got used to having this kind of convention with C. I'm pretty sure that it works this way in Java to keep some kind of syntax consistency with older languages.