public Student[] getStudents() { Student[] student=null; try { int pin=0;String name=null; byte[] byteInputData = new byte[100]; RecordStore rs=Utility.getStudentRecordStore(); ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData); DataInputStream inputDataStream =new DataInputStream(inputStream); int noOfRecords=rs.getNumRecords(); student=new Student[noOfRecords]; for (int x = 1; x <= rs.getNumRecords(); x++) { rs.getRecord(x, byteInputData, 0); name=inputDataStream.readUTF(); pin=inputDataStream.readInt(); student[x-1].setName(name); student[x-1].setPin(pin); inputStream.reset(); } inputStream.close(); inputDataStream.close(); return student; } catch (Exception error) { } return student; }
QQ. Above method is not returning array of students although the student.length is providing a proper answer please help me