Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zsolt_3ora;
- import java.util.Arrays;
- import java.util.Comparator;
- public class Zsolt_3ora {
- public static void main(String[] args) {
- /*
- int t[];
- t = new int[10];
- t[0] = 7;
- t[1] = 4;
- t[2] = 2;
- t[3] = 0;
- t[4] = 9;
- t[5] = 1;
- t[6] = 5;
- t[7] = 8;
- t[8] = 6;
- t[9] = 3;
- */
- /*
- int[] t;
- int a, b, c;
- t = new int[] {7, 4, 2, 0, 9, 1, 5, 8, 6, 3};
- */
- int[] t={7, 4, 2, 0, 9, 1, 5, 8, 6, 3};
- int a, b, c;
- System.out.println(t);
- System.out.println(Arrays.toString(t));
- for (int i = 0; i < t.length; i++) {
- if (i > 0) {
- System.out.print(" ");
- }
- System.out.print(t[i]);
- }
- System.out.println(System.getProperty("line.separator"));
- System.out.println("The End");
- for (int u : t) { //bejΓ‘rja a tΓΆmb elemeit egyszer
- System.out.println(u);
- }
- Integer[] ti= new Integer[t.length];
- for (int i = 0; i < ti.length; i++) {
- ti[i] = t[i];
- }
- Arrays.sort(t);
- System.out.println(Arrays.toString(t));
- System.out.println(Arrays.toString(ti));
- Comparator<Integer> s = new sajat_comparator();
- Arrays.sort(ti,s);
- System.out.println(Arrays.toString(ti));
- }
- }
- //sajat_comparator
- package zsolt_3ora;
- import java.util.Comparator;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author hallgato
- */
- public class sajat_comparator implements Comparator<Integer> {
- @Override
- public int compare(Integer o1, Integer o2) {
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- if (o1 < o2){
- return -1;
- }
- if (o1 > o2){
- return 1;
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement