title: How do you Increment an Integer inside a While loop and convert it to String?
body: <pre><code>StyledDocument doc = txtpaneExamGeneration.getStyledDocument();
  
      Connection con = null;
      Statement stmt = null;
      try {
          Class.forName("org.sqlite.JDBC");
          con = DriverManager.getConnection("jdbc:sqlite:sql_items.sqlite");
          stmt = con.createStatement();
          ResultSet rs = stmt.executeQuery("SELECT item_desc FROM active_items ORDER BY random();");
  
          while(rs.next()){
              int num = 1;
              String itemNumbering = Integer.toString(num);
              String stringHandler = rs.getString("item_desc");
              doc.insertString(doc.getLength(), Integer.toString(num) + ". _______________ - " , null);
              doc.insertString(doc.getLength(), stringHandler + ".\n\n", null);
              num++;
          }
      } catch (ClassNotFoundException | SQLException e) {
          System.out.println(e);
      } catch (BadLocationException ex) {
          Logger.getLogger(generateExam.class.getName()).log(Level.SEVERE, null, ex);
      }
  </code></pre>
  
  <p>The objective of the program is to append and display the contents of a database to a <code>JTextPane</code>. I want to list them with incrementing numbering by declaring an integer inside the while loop and then convert that to string and then increment it for the next iteration of the loop.</p>
  
  <p>the output goes like this:</p>
  
  <pre><code>1. ____________ - item 1
  
  1. ____________ - item 2
  
  1. ____________ - item 3
  
  1. ____________ - item 4
  </code></pre>
  
  <p>I cannot understand why it is not incrementing the numbering. Can someone please help</p>