title: How to store the local variables data to global variables in the same class and use it
body: <p>Im facing a problem whereby I need to use an updating string data from a method in the same class. should i create a global variables? and if so, how could I place the updating string data to the global variables? below is my code whereby comment are added to illustrate more detail.</p>
  
  <pre><code>public class GenerateSummonPDF
  {
  
  
  public void userdata(String p1, String p2, String p3, String p4)
  {
      String value1= p1;
      String value2= p2;
      String value3= p3;
      String value4= p4; // all the data here are constantly updating from other class
  
  
  
  }
  public static void main(String[] args)
  {
  
    Document document = new Document();
    try
    {
       PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("C:\\Users\\User\\workspace\\enforement system\\Summon PDF list\\Serial No.pdf"));
       document.open();
       document.add(new Paragraph("")); //i need to print all the data here from the userdata
       document.close();
       writer.close();
    } catch (DocumentException e)
    {
       e.printStackTrace();
    } catch (FileNotFoundException e)
    {
       e.printStackTrace();
    }
   }
  </code></pre>
  
  <p>Is there any solution for that? Thanks for help in advance.</p>