Title: Enter a string of characters, made up of () {}[], to determine if all the parentheses are closed brackets, yes returns true, not return false.
/* Input string, disassembled as a character array
* Use function S.charat (i) to complete
*
* */
Import java.util.*;
Import java.lang.*;
public class Char {
public static void Main (string[] args) {
String A=new string ();
Scanner in=new Scanner (system.in);
A=in.next ();
Char[]b=new char[100];
Boolean bool=true;
for (int i=0;i<a.length (); i++) {
B[i]=a.charat (i);
}
for (int i=0;i<a.length (); i++) The length of the {///array. length; lengths of strings. Length ()
if (b[i]== (' {')) {//char is the base type, this cannot be used with equals ()
if (b[i+1]== '} ')
Continue
else{
Bool=false;
Break
}
}
if (b[i]== ' (') {
if (b[i+1]== ') ')
Continue
else{
Bool=false;
Break
}
}
if (b[i]== ' [') {
if (b[i+1]== '] ') {
Continue
}
else{
Bool=false;
Break
}
}
Bool=true;
}
if (bool==true)
System.out.println ("True");
Else
System.out.println ("False");
}
}
How to split a string into a character array in Java