0

For instance if I hav this array

String[] cars = {"Tesla", "Ford", "Toyota", "Rolls Royce"};

and I would like to remove the "Ford". Is there a simple function like cars.strip[1] to remove it in java?

  • 5
    Arrays are fixed-size in Java. You'll have to create a copy. – shmosel Jul 06 '22 at 05:05
  • 6
    You might want to use a collection here, such as a `List`, which allows for removal of individual elements with minimal fuss. – Tim Biegeleisen Jul 06 '22 at 05:07
  • The answer is no. For every array type corresponding classes are available and these classes are the part of java language and not available to the programmer level. You can anytime check it by your own by writing the dot and see what methods are available. You have to create your own method "strip" by giving the array as parameter and do the things you need – Melron Jul 06 '22 at 06:17

0 Answers0