Question: Write a method that takes a string of curly brackets and returns true if the brackets match up and false if they dont. These are

Write a method that takes a string of curly brackets and returns true if the brackets match up and false if they dont.

These are examples of brackets matching:

{} {}{} {{}} {{{}{{}}}}

These are examples of the brackets not matching:

{ }{ {{} {{}}}{}

If you are passed the empty string, you should return true.

You can assume the given string will only have { and } in it (or be empty).

public boolean bracketsMatch(String brackets) { }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!