I have an byte array in Java and need to get parts of it. I wanted to work with Java arrays in the same way as I work with Python list, using slices. There is something similar to this in Java? Thank you in advance.
Advertisement
Answer
You can use Arrays’ (https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/util/Arrays.html) built-in Arrays#copyOfRange()
Arrays.copyOfRange(oldArray, startIndex, endIndex);