This will bring to mind the typical create a star triangle with the right angle on the right, whereby each line has a number of white spaces preceding the *, ie
*
**
***
****
and so forth.
In brief I have an ArrayList, whereby each element is of type String. So that in the first element: I may have public class hi{, second: public void run(){, third: if (this) return that, and fourth: public void eat(){, etc...
I have created a method which traverses each String element in search of the "{" (which it has trimmed of all the preceding white spaces to make the indentation easy). On finding this {, the program should insert a x number of whitespaces before depending on the order in which the "{" appears in the array. For instance, referring back to my example, on finding the first bracket, the first element is left as it is no white space is inserted before the element. Yet, on find the second bracket, I want that element to be indented a number of white spaces (or pixels if you suggest I use HTML tags here). The on finding the third, the element is indented a bit further and so forth.
How do you suggest I implement this? I was thinking of getting the element index so that if i = 1, white spaces = i - 1 (number of times some while loops in my class will be executed to output that whitespace). Likewise, if i = 2, white space inserted = 1 and so forth...This may work, but it is not particularly interesting...
Many thanks!