“Array Reverse in Java” Code-Antworten

Reverse Array Java

//With Commons.Lang, you could simply use

ArrayUtils.reverse(int[] array)

// For reversing subarray
ArrayUtils.reverse(int[] array,int startIndexInclusive, int endIndexExclusive)


Spotless Shark

Array Reverse in Java

        int[] xr = {1, 2, 3, 4, 5};

        System.out.print("[");
        for (int i = xr.length - 1; i >= 0; i--) {
            System.out.print(xr[i] + ", ");
        }
        System.out.println("\b\b]");
    }
Chathumal Sangeeth

Rückwärts in Jaav

// my linkedin : https://www.linkedin.com/in/vaalarivan-prasanna-3a07bb203/
list = new ArrayList<int> {3, 4, 7};  //initialising a list
Collections.reverse(list);  //reverses a List or an ArrayList
//now, list is {7, 4, 3}
My real name : Vaalarivan P

Reverse Int Array Java

import java.util.*;
import java.util.stream.Collectors;

int[] array = new int[] {23, 54, 12};
List<Integer> list = Arrays.stream(array).boxed().collect(Collectors.toList());
Collections.reverse(list);
array = list.stream().mapToInt(x -> x).toArray();
//array = [12,54,23]
Cheerful Cowfish

Java umkehren

public void reverse()
    {
        for (int i = 0; i < size/2; i++)
        {
            int temp = get(i);
            elementData[i] = elementData[size-i-1];
            elementData[size-i-1] = temp;
        }
    }
Sid Potti

Java Reverse Array

WWWWW-
S---W-
W-W-W-
W-W---
E-W-W-
WWWWW-
Uninterested Unicorn

Ähnliche Antworten wie “Array Reverse in Java”

Fragen ähnlich wie “Array Reverse in Java”

Weitere verwandte Antworten zu “Array Reverse in Java” auf Java

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen