Main - studentList.add(s); }...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.*; import java.util.*; i public class Main { p public static void main(String[] args) { MyArrayList<Student> studentList = new MyArrayList<Student>(); Scanner in = null; try { File file = new File("studentData.txt"); in = new Scanner(file); int j = 0; while(in.hasNextLine()) { String line = in.nextLine(); String[] sInfo = line.split(","); Student s = new Student(sInfo[0], sInfo[1], sInfo[2], sInfo[3], Double.parseDouble(sInfo[4]));
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: studentList.add(s); } //studentList.add(&quot;Test&quot;); for (int i = 0; i &lt; studentList.size(); i++ ) System.out.println(studentList.get(i)); S System.out.println(&quot;\n&quot;); S studentList.remove(2); for (int i = 0; i &lt; studentList.size(); i++) System.out.println(studentList.get(i)); S } catch (Exception e) { System.out.println(e); } finally { f if(in != null) in.close(); } } }...
View Full Document

Ask a homework question - tutors are online