I am trying to achieve below output
A1 = 123 then in next line A2= 456 and A3 = 678
But when I run this, it's going in a loop and getting 10 times. I just need these 3 lines like A1 ,A2 and A3. Length can change based on demand. Below is my code. Please suggest a solution.
public class SusbTesting {
public static void main (String args[]){
String text = "123456789"; //The text
int len = text.length(); //Get the length
// text = text.substring(0,4)+ "_"+ text.substring(4,6) + "-" + text.substring(6);
System.out.println("testing test >>>" +text);
for (int k = 0; k < text.length(); k++)
{
String A1 = text.substring(0,2);
String A2 = text.substring(3,6);
String A3 = text.substring(7,9);
text = A1+ "_"+ A2 + "-" + A3;
System.out.println("testing >>>" +text);
}
}
}