I am making a project in Number Theory and i want to display
some formatting text in a textArea in my Gui.
I have a method named padding which takes an integer as an argument
and return a String consisitng of a number of spaces.
This number is 12 - the number of the given integer length.
public String padding(int number){
int NumberOfDigits ;
String padding = "";
NumberOfDigits = 12 - Integer.toString(number).length();
for (int j = 0; j < NumberOfDigits; j++) {
padding +=" ";
}
return padding;
}
I am using this method like this :
for (i = 2 ; i < number; i++){
if (isPrime(i) && (number % i == 0)){
textAreastring += padding(number) + number + padding(number) + " : " + padding(i) + i + padding( i) + " = " + padding( number / i) + number / i + " " + newline;
listint.add(i);
number = number/i;
i--;
}
Is there a way using String methods to produce the same formatting?