Questions tagged [braces]

The symbols "{" and "}", commonly used in programming languages. Please use this tag only if the specific usage of these symbols is a relevant part of the question.

The curly brackets (or braces) "{" and "}" are special cases of brackets, along with parentheses and square brackets ("[" and "]").

Curly brackets have many uses in most programming languages, such as:

  • identify code blocks;
  • create lists and arrays;
  • pass arguments to commands in TeX.
170 questions
-2
votes
4 answers

Java regex for inserting text between braces

I have a String a = "stringWithBraces()" I want to create the following string "stringWithBraces(text)" How do I achieve this using regex? I tried this : a.replaceAll("\\(.+?\\)", "text"); But get this : stringWithBraces()
user_mda
  • 12,733
  • 17
  • 62
  • 111
-2
votes
3 answers

Java bracket issue

I think I am missing brackets somewhere but I have been searching for 3 hours and cannot find what is wrong, nor has googling helped me at all. I tried adding end braces/brackets to the if then statements but then I get a bunch of errors. Probably…
-3
votes
1 answer

Why in programming are the braces not arranged next to the text they enclose?

(12193170: not the same question (or not the right answers for that matter...)) So basically why this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } } And not this: public class…
Emdosis
  • 1
  • 7
-5
votes
2 answers

Export all braces in a String to an array

example: String = "(a(b[}7cv)))" the array should look like this: ["(","(","[","}",")",")",")"] my try: if(s.charAt(i) == "(" ){ //add to array}
Zireal
  • 1
  • 1
-6
votes
1 answer

Code fails when class definition closed

I'm a beginner to Java trying to understand why my program works when it seems like it shouldn't. When I try and compile the code below, I get the error "class, interface, or enum expected" and it points to the brace on the final line of the…
fauxfaux
  • 1
  • 1
1 2 3
11
12