title: How to use List in another function
body: <p>--------------------------------------Table 1--------------------------------------</p>
  <pre><code>@Entity
  @Table(name = &quot;student_details&quot;)
  public class StudentDetails {
      
      @Id
      private Long studentId;
      private String firstName;
      private String lastName;
      private String fatherName;
      
      // with getter and setters
      
  }
  </code></pre>
  <p>-------------------------------------Table 2---------------------------------</p>
  <pre><code>@Entity
  @Table(name = &quot;student_marks&quot;)
  public class StudentMarks {
      
      @Id
      private Long studentId;
      private int Maths;
      private int English;
      private int Computer;
      
      // with getter and setters
      
  }
  </code></pre>
  <p>------------------------------------class which combine these two table------------------</p>
  <pre><code>public class StudentReportData {
  
      @Id
      private Long studentId;
      private String studentName
      private String fatherName;
      private int Maths;
      private int English;
      private int Computer;
      
      //with getter and setters
      
  }
  </code></pre>
  <p>-----------------------------------Service Class---------------------------</p>
  <pre><code>@Service
  public class StudentService {
  
      public ApiResponce&lt;List&lt;StudentReportData&gt;&gt; getStudentData() {
      
          ApiResponce&lt;List&lt;StudentReportData&gt;&gt; responce = new ApiResponce();
          Status status = new Status();
          status setSuccess(true);
          try {
              List&lt;StudentReportData&gt; studentList = new ArrayList&lt;StudentReportData&gt;();
              List&lt;StudentMarks&gt; findAll = studentMarksRepository.findAll();
              for(StudentMarks sm : findAll) {
                  StudentReportData studentData = new StudentReportData();
                  BeanUtils.copyProperties(sm, studentData);
                  StudentDetails studentDetailsData = studentDetailsRepository.findByStudentId(sm.getStudentId());
                  studentData.setStudentName(studentDetailsData.getFirstName()+&quot; &quot;+studentDetailsData.getLastName());
                  studentList.add(studentData);
              }
              response.setData(studentList);
          } catch (Exception ex) {
              ex.printStackTrace();
              ErrorData errorData = new ErrorData();
              errorData.setErrorCode(&quot;ERR003&quot;);
              errorData.setErrorMessage(&quot;Internal Server Error&quot;);
              status.setErrorData(errorData);
              status.setSuccess(false);
          }
          response.setStatus(status);
          return response;
      
      }
      
      
      public ByteArrayInputStream load() {
          
      
          ByteArrayInputStream in = ExcelHelper.studentreportToExcel(studentList);
          return in;
        }
      
      
  }
  </code></pre>
  <p>I want to pass this studentList as an argument to the function <code>studentReportToExcel</code> from the function <code>load</code>. How can I get that List Inside the <code>load</code> function.</p>