title: Fundamentals In creating a better Text with java
body: <p>There are some versions of the java compiler where the sort() method of the Vector class is not yet implemented. If you are not using JDK 1.8 version or higher, use the Collections class instead to sort your Vector data. Sample use below</p>
  <p>There are some versions of the java compiler where the sort() method of the Vector class is not yet implemented. If you are not using JDK 1.8 version or higher, use the Collections class instead to sort your Vector data. Sample use below</p>
  <pre><code>import java.io.BufferedReader;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.io.FileReader;
  import java.io.InputStreamReader;
  import java.util.Arrays;
  import java.util.Scanner;
  import java.util.Vector;
  
  public class Main {
  
      /**
       * @param args the command line arguments
       */
      public static void main(String[] args) throws IOException {
          try {
              BufferedReader br = new BufferedReader(new FileReader(&quot;c://student.txt&quot;));
              char g;
              int yl, I;
              String ln, fn, id, cors, con;
              Student v[] = new Student[4];
              Scanner sc = new Scanner(System.in);
              boolean en = true;
              boolean ent = true;
  
              for (i = 0; i &lt; 4; i++) {
                  id = br.readLine();
                  ln = br.readLine();
                  fn = br.readLine();
                  g = br.readLine().charAt(0);
                  cors = br.readLine();
                  yl = Integer.parseInt(br.readLine());
  
                  v[i] = new Student(ln, fn, id, cors, g, yl);
              }
  
              while (en == true) {
                  System.out.println(&quot;--------------------------------------&quot;);
                  System.out.println(&quot;--------------------------------------&quot;);
                  System.out.println(&quot;1. Name&quot;);
                  System.out.println(&quot;2. Course then Name&quot;);
                  System.out.println(&quot;3. Year Level then Name&quot;);
                  System.out.println(&quot;4. Course then Year Level and the Name&quot;);
                  System.out.println(&quot;5. Exit&quot;);
                  System.out.println(&quot;--------------------------------------&quot;);
                  System.out.println(&quot;--------------------------------------&quot;);
                  System.out.println(&quot;Choose Menu: &quot;);
                  int choice = sc.nextInt();
                  switch (choice) {
                      case 1:
                          Arrays.sort(v);
                          display_array(v);
                          break;
                      case 2:
                          Arrays.sort(v);
                          display_array(v);
                          break;
                      case 3:
                          Arrays.sort(v);
                          display_array(v);
                          break;
                      case 4:
                          Arrays.sort(v);
                          display_array(v);
                          break;
                      case 5:
                          en = false;
                          System.out.println(&quot;\n\n \nTHANK YOU FOR USING THE PROGRAM!!&quot;);
                          break;
                  }
                  if (en != false) {
                      System.out.println(&quot;Press [Enter key] to continue&quot;);
                      try {
                          System.in.read();
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                  }
              }
          } catch (FileNotFoundException e) {
              System.err.println(&quot;File not found&quot;);
          } catch (IOException e) {
              System.err.println(&quot;Unable to read the file.&quot;);
          }
      }
      public static void display_array(Student arr_v[]) throws IOException {
          System.out.println(&quot;--------------------------------------&quot;);
          for (int i = 0; i &lt; arr_v.length; i++) {
              arr_v[i].display();
          }
          System.out.println(&quot;--------------------------------------&quot;);
      }
  }
  
  public class Student implements Comparable {
      private String lastname, firstname, studentid, course;
      private char gender;
      private int yearlevel;
  
      public Student(String ln, String fn, String id, String cors, char g, int yl) {
          lastname = ln;
          firstname = fn;
          studentid = id;
          course = cors;
          gender = g;
          yearlevel = yl;
      }
  
      public int compareTo(Object anotherObject) {
          Student anotherStudent = (Student) anotherObject;
          int compareResult =
              this.course.compareTo(anotherStudent.lastname);
          if (compare)
              return 0;
      }
      public void display() {
          System.out.printf(&quot;ID: %-8s  Name: %-20s  Sex: %c  Course: %-8s  Year: %d\n&quot;, studentid, (lastname + &quot;, &quot; + firstname), gender, course, yearlevel);
      }
  
      public void setGender(char gender) {
          this.gender = gender;
      }
  
      public char getGender() {
          return gender;
      }
  
      public void setLastname(String lastname) {
          this.lastname = lastname;
      }
  
      public String getLastname() {
          return lastname;
      }
  
      public void setFirstname(String firstname) {
          this.firstname = firstname;
      }
  
      public String getFirstname() {
          return firstname;
      }
  
      public void setStudentId(String studentid) {
          this.studentid = studentid;
      }
  
      public String getStudentId() {
          return studentid;
      }
  
      public void setCourse(String course) {
          this.course = course;
      }
  
      public String getCourse() {
          return course;
      }
  
      public void setYearLevel(int yearlevel) {
          this.yearlevel = yearlevel;
      }
  
      public int getYearLevel() {
          return yearlevel;
      }
  }
  
  </code></pre>