Quantcast
Channel: VBForums - Java
Viewing all articles
Browse latest Browse all 41

print array in the shape of a figure 8

$
0
0
Hi I have an java project which prints an array using the follwing loop:

Code:

        String tempString2 = ""; 
          for (int i=0; i<19; i++) {
                      tempString2 = tempString2 + trackSections[i];

However i need to print the array in the shape a figure 8 so that is looks like:

Code:

[]
  []  []
 []    []
 []    []
  []  []
    []
 []  []
[]      []
[]      []
 []  []
    []



I have tried declaring my array like this :

Code:

        private String [] trackSections= {"","","[..]","","", + '\n' + "","[..]", "","[..]", "" + '\n' + "[..]","","","","[..]", + '\n' + "[..]","","","","[..]",
                + '\n' + "","[..]", "","[..]", +'\n'+ "","","[..]","","", + '\n'+ "","[..]", "","[..]", "" + '\n' + "[..]","","","","[..]", + '\n' + "[..]","","","","[..]",
                        + '\n' + "","[..]", "","[..]", ""+'\n'+  "","","[..]","","",};

but the array just prints in a straight line.

Can anyone help me with this ?

Thanks

Viewing all articles
Browse latest Browse all 41

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>