Hi everybody.
I'm trying to split a string such that every array element would have characters between open and close prentesis.
mmm let me just show:
myString = "(2*((3-2)+(5-3)))"
So my array should have values like that:
myArray[0] = 2*((3-2)+(5-3));
myArray[1] = (3-2)+(5-3);
myArray[2] = (3-2);
myArray[3] = (5-3);
I tryed to do that by using .split() but
Here is my code and output:
public class P2 {
public static void main(String[] args) {
new P2();
}
public P2() {
String myString = "(2*((3-2)+(5-3)))";
String myArray[] = myString.split("\\(");
for(int i=(myArray.length-1); i>=0; i--)
System.out.println("myArray["+i+"] : "+ myArray[i]);
}
}
myArray[4] : 5-3)))
myArray[3] : 3-2)+
myArray[2] :
myArray[1] : 2*
myArray[0] :