I am learning Java.
In Python, I can:
my_list = [1,2,3,4]
my_new_list = my_list [::-1]
print my_new_list
Is there any method that I can use in Java to do this in an int array?
Edit1: Sorry for the bad example. What about my_list [:: - 2]?
Edit2: I mean that my_list [:: - 2] is similar to
my_list = [1,2,3,4]
my_new_list = my_list [::-2]
print my_new_list
Edit3: Slicing step by step in Python is to "check" an element in the list at each step (step). If the step is negative, Python will check the item from the end of the list to the beginning of the list. For example:
my_list = [1,2,3,4,5,6,7,8,9]
my_list1 = my_list[::2]
my_list2 = my_list[::3]
my_list3 = my_list[::4]
my_list4 = my_list[::-3]
source
share