Skip to main content
3 of 5
fixed typo, improved wording
honk
  • 9.7k
  • 4
  • 38
  • 48

First of all, I disagree that the question is too broad. But one would first have to clarify exactly what the question is. The first revision asks for the meaning of { -- which begs the question: in which context? What does the asker really wants to know, and what kind of answer are they looking for?

Curly-braces, in and of themselves, are a lot of different "meanings", depending on what "meaning" represents:

I could go on like this, there are hundreds of possibilities here, and I suspect each and every one of them already has a (or probably, multiple) questions about it. Is the OP asking for one of those meanings? I suspect this is why the question was closed as too-broad: if one would have to get into all of the possible usage of the curly-brace, explaining how it pertains to each and every combination, it would really be too broad.

If we replay the history here, what happened is that an unclear question (see above), obviously not researched (searching for Google "java what does curly brace mean site:stackoverflow.com" yields all of the questions I linked above, no exceptions, and removing the "site:stackoverflow.com" returns other blogs or articles talking about each usage as well, in the pages of pages of results) was answered with "The question is not so great". The answer followed to talk about the possible meanings I quoted above, best guess they could make. At that point in time, the thing deserved to die because of that.

Somehow, the question had a lot of attraction, no idea why, as those type of unclear questions with guesses as answers are a daily problem (or even a hourly problem) and constant source of pain in the Java tag. In all the confusion and excitement, edits focused on trying to have a definite answer by rewording to "Is there a universal meaning?". Funnily enough, no, there isn't. The Java Language Specification uses the curly-brace as the beginning of a block. A block actually encompasses practically all of the structures and contexts shown above in a single concept. Except for the case of the initialization of arrays, that isn't a block and doesn't fall under this universal meaning.

I won't count the amount of time that has passed into trying to salvage the thing, on Meta, on the various votings and queues, but it's impressively too great. In any case, the edited question, (that invalidated the answers) can be answered with "No". I don't believe this is helpful and I don't believe people reading it will learn things from it, for the sole reasons that the next question is going to be "What is the meaning of a block?", which is too broad to answer. If we remove arrays of the equation, it is a duplicate of this question.

Tunaki
  • 136.8k
  • 6
  • 55
  • 65