Please, help me with my code. I want to do merge sort from simple user input, but keeps show "-Xlint ..." when compile it. Also, it's not working as expected...
import java.util.*; import java.io.*; //import java.util.StringTokenizer; /** * * @author rus.ardhiyanto */ public class SDA1 { private static String Sip = " Sender "; private static String Jam = " Clock "; private static String Judul = " Subject "; public static void main(String args[]) { String [] no = new String [3]; try { System.out.println("Sender Subject Clock"); System.out.println(); InputStreamReader input = new InputStreamReader(System.in); BufferedReader baca = new BufferedReader (input); String urut = new String (); String sender = new String (); String time = new String (); String subject = new String (); List <Email> imel = new ArrayList <Email> (); if ((urut = baca.readLine()) != null) { no = urut.split(" "); } while ((urut = baca.readLine()) != null) { StringTokenizer token = new StringTokenizer(urut); sender = token.nextToken(); time = token.nextToken(); subject = " "; while (token.hasMoreTokens()) { subject += token.nextToken(); } Clock hour = new Clock (time); imel.add (new Email(sender, hour, subject)); } Sortir sortir = new Sortir (); String[] strTemp = new String[imel.size()]; String strTem = " "; for (int i = 0; i < imel.size(); i++) { for (int j = 0; j < no.length; j++) { if (no[j].equals(Sip)) { strTem += imel.get(i).getSender() + " "; } else if (no[j].equals(Jam)) { strTem += imel.get(i).getClock().toString() + " "; } else if (no[j].equals(Judul)) { strTem += imel.get(i).getSubject() +" "; } } strTemp[i] = strTem; strTem = " "; } sortir.mergeSort(strTemp); for (int i = 0; i < imel.size(); i++) { System.out.println(strTemp[i]); } } catch (Exception ex) { } } } class Sortir { List getSortbySender(List Email) { List ListTemp = null; return ListTemp; } private void merge (Comparable[] a, Comparable[] tmpArray, int Kiri, int Kanan, int KananPol) { int KiriAbis = Kanan - 1; int tmpPos = Kiri; int jmlElements = KananPol - Kiri + 1; while (Kiri <= KiriAbis && Kanan <= KananPol) { if (a[Kiri].compareTo(a[Kanan]) <= 0) { tmpArray[tmpPos++] = a[Kiri++]; } else { tmpArray[tmpPos++] = a[Kanan++]; } } while (Kanan <= Kiri) { tmpArray[tmpPos++] = a[Kiri++]; } while (Kanan <= Kiri) { tmpArray[tmpPos++] = a[Kanan++]; } for (int i = 0; i < jmlElements; i++, KananPol--) { a[KananPol] = tmpArray[KiriAbis]; } } private void mergeSort (Comparable[] a, Comparable[] tmpArray, int kiri, int kanan) { if (kiri < kanan) { int tengah = (kiri + kanan) / 2; mergeSort (a, tmpArray, kiri, tengah); mergeSort (a, tmpArray, tengah + 1, kanan); merge(a, tmpArray, kiri, tengah + 1, kanan); } } public void mergeSort (Comparable a[]) { Comparable[] tmpArray = new Comparable[a.length]; mergeSort(a, tmpArray, 0, a.length - 1); } } class Email { private String sender; private String subject; private Clock clock; Email(String sender, Clock clock, String subject) { this.sender = sender; this.clock = clock; this.subject = subject; } String getSender() { return sender; } void setSender(String sender) { this.sender = sender; } String getSubject() { return subject; } void setSubject(String subject) { this.subject = subject; } Clock getClock() { return clock; } void setClock(Clock clock) { this.clock = clock; } @Override public String toString() { return sender + " " + clock + " " + subject; } } class Clock { private Integer hour; private Integer minute; Clock(String time) { StringTokenizer tok = new StringTokenizer(time, ":"); hour = Integer.parseInt(tok.nextToken()); minute = Integer.parseInt(tok.nextToken()); } Integer getHour() { return hour; } void setHour(Integer hour) { this.hour = hour; } Integer getMinute() { return minute; } void setMinute(Integer minute) { this.minute = minute; } @Override public String toString() { String out = ""; if (hour < 10) { out += "0" + hour; } else { out += hour; } out += " "; if (minute < 10) { out += "0" + minute; } else { out += minute; } return out; } }
thank you