B
B
Boris Goncharov2020-05-08 22:48:55
Java
Boris Goncharov, 2020-05-08 22:48:55

Remove argument with index from array?

There is a variable: String[] args, in it, three words (any, it doesn't matter.). How can I remove one of them, so that later I can do everything through String.join ()? I tried to assign the value "" to some indexes, but it showed an extra space. How can such a thing be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lyoshik, 2020-05-08
@BarashkaDev

String[] array = new String[] {"a", "b", "c"};
String[] newArray = Stream.of(array).filter(it -> !it.equals("b")).toArray(String[]::new);

for (String it : newArray) {
     System.out.println(it);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question