Advertisement
Guest User

sdfdsgdg

a guest
Apr 24th, 2014
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 1.05 KB | None | 0 0
  1. import java.util.List;
  2. import java.util.ArrayList;
  3. import java.util.Arrays;
  4.  
  5. interface Student{
  6.         String kierunek = "Informatyka";
  7.  
  8.         String getK();
  9. }
  10.  
  11. public class StudentInformatyki implements Student, Comparable<StudentInformatyki>{
  12.         int indeks;
  13.  
  14.         int getI(){
  15.                 return this.indeks;
  16.         }
  17.  
  18.         void setI(int indeks){
  19.                 this.indeks = indeks;
  20.         }
  21.  
  22.         public String getK(){
  23.                 return kierunek;
  24.         }
  25.  
  26.         public StudentInformatyki(int indeks){}
  27.  
  28.         public static void main(String[] args){
  29.                 StudentInformatyki A[] = new StudentInformatyki[4];
  30.  
  31.                 A[0] = new StudentInformatyki(343);
  32.                 A[1] = new StudentInformatyki(341);
  33.                 A[2] = new StudentInformatyki(345);
  34.                 A[3] = new StudentInformatyki(342);
  35.  
  36.                 for(int i=0; i<4; i++){
  37.                         System.out.println(A[i].getI());
  38.                 }
  39.  
  40.                 Arrays.sort(A);
  41.  
  42.         }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement