basically, I want to try out the persistence bugger and I'm new to java coding so I'm still using NetBeans GUI to code (I know) but I need help to make it work. Have attached my efforts below. The GUI is just a textField that takes input and a button with the given code. If someone could help that would be great. Thanks in advance.
The error I kept getting was: Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: 4 (4 is the length of the number I entered. It kept varying accordingly)
long num1=Long.parseLong(jTextField1.getText());
String num2=jTextField1.getText();
char s1;
int pers=1,temp;
for(int i=1;i<=num2.length();i++)
{
  s1=num2.charAt(i);
  temp=Character.getNumericValue(s1);
  pers*=temp;
  if(pers==0)
   {
    System.out.println(i);
    break;
   }
}
String num2=jTextField1.getText();
String test=num2;
char s1;
int pers=num2.length(),temp=1,i,n=0;
  do
  {
      for(i=0;i<pers;i++)
   {
    s1=test.charAt(i);
    temp=temp*(Character.getNumericValue(s1));
   }
    test=Integer.toString(temp);
    temp=1;
  } while(test.length()>1);
  System.out.println(n);
  Final working code:
  long r1=Long.parseLong(jTextField1.getText());
  String s=jTextField1.getText(),s1="";
  long r=1;
  int i=0;
  char[] gfg=s.toCharArray();
  do
   {
    for (char ch : gfg) 
     {
      r *= Character.digit(ch, 10);
     }
      s1=Long.toString(r);
      gfg=s1.toCharArray();
      System.out.println(r);
      r=1;
   }while(s1.length()!=1);
 
     
    