/ Published in: Java

this is a snippet from a parsing piece of code I had to do for class, basically I had to grab employee names, numbers, paycodes, hours worked, etc. and organize it. In order to align the columns I ended up using some code like this
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
for(i = 0; i < lastName.length; i++){ chars[i] = (firstName[i] + lastName[i]).length(); chars[i] = 17 - chars[i]; //use larger number if strings are bigger spaces[i] = ""; while (chars[i]>0){ chars[i]--; spaces[i] += " "; } newArray[i] = lastName[i] + ", " + firstName[i] + spaces; /* * Nick Stanish * newArray[i] is the formatted column, if the arrays are confusing * then replace with a single string for easer readability */ } //display
Comments
