Java eqivalent method of “splice(a,b,…)” in JavaScript method

someArray.splice(a,b,...) method in JavaScript adds or removes items to/from array. What could be good and simple solution to implement such method in Java language? Assume we have String[] array.


In standard Java libraries, there is no equivalent functionality.

There is java.util.Arrays class, but no similar functionality there.


Java arrays have a fixed length, so this cannot be done directly.

If you want to combine two arrays, look at this answer.

If you want to add to the array, you should use a List or an ArrayList instead.


I misread your question and mixed up splice and slice.

The class java.util.Arrays provides some static functions useful when working with arrays. See the official documentation for other functions:

Java's equivalent for slice is: Arrays.copyOfRange(array, from, to).

A similar method to splice is addAll ( But you need to use a java.util.ArrayList instead an array and it is not possible to remove elements with it. You would have to provide the elements as another collection, e.g. an ArrayList. So it is equivalent to calling splice(index, 0, element1, element2, ...)


I have code like this: TextBox txt = new TextBox(){ public void onLoad(){ this.addFocusHandler(new FocusHandler(){ //some codes here //if I use "this" keyword, it refers to the ...

I want the functionality of the Stanford Core NLP, written in java, to be available in C++. To do this I am making use of the Java Native Interface. I have a Java object that wraps multiple functions ...

I am successfully parsing and evaluating a javascript file with Duktape in my Android application using Kotlin. val file_name = "lib.js" val js_string =

I'm using this class as my key to Hashmap with overriden hasCode() and equals() public class Design { private double[] factors = null; public double[] getFactors() { return factors; } public ...