Auf Thema antworten

so etwa :

[code=Java]    public ArrayList<Integer> getSingleInts(int[]a,int[]b){

        ArrayList<Integer> nurEinMal = new ArrayList<>();

        Arrays.stream(a).filter(e -> onlyOnce(e,a,b))

                        .forEach(e -> nurEinMal.add(e));

        Arrays.stream(b).filter(e -> onlyOnce(e,a,b))

                        .forEach(e -> nurEinMal.add(e));

        return nurEinMal  ;

       

    }[/code]

Als Ergebnis hättest du dann eine ArrayList mit INTEGER werten ( nicht int ).

sonst so :

[code=Java]    public int[] getNurEinMal(int[]a,int[]b){

        int[]c = new int[a.length+b.length];

        int indexInC = 0 ;

        for ( int i = 0 ; i < a.length ; i++){

            if( onlyOnce(a[i],a,b)){

                c[indexInC]= a[i];

                indexInC++;

            }

        }

        for ( int i = 0 ; i < b.length ; i++){

            if( onlyOnce(b[i],a,b)){

                c[indexInC]= b[i];

                indexInC++;

            }

        }

        return c ;

    }[/code]



Oben