Advertisement
niske

Untitled

Oct 23rd, 2024
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import java.util.Comparator;
  2.  
  3. public class PoredjenjePoRediteljuNazivu implements Comparator<Film> {
  4. @Override
  5. public int compare(Film film1, Film film2) {
  6. int num = film1.naziv.compareTo(film2.naziv);
  7. if(num > 0) {
  8. return 1;
  9. }
  10. else if(num < 0) {
  11. return -1;
  12. }
  13. else {
  14. num = film1.naziv.compareTo(film2.naziv);
  15. if(num > 0) {
  16. return 1;
  17. }
  18. else if(num < 0) {
  19. return -1;
  20. }
  21. else {
  22. return 0;
  23. }
  24. }
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement