0

When we declare an String array in Java

String[] obj =new String[10];

When we print this it return null value by default

But I want to change this null to empty strings but without using loop

Can someone tell me how can I declare an array with value of empty string

You can use any ds to store strings like arraylist arrays etc but by default value should be empty string not null

Array size is variable and using different arrrays

4
  • 1
    Why don't you want to use a loop? What's wrong with a loop? Commented Apr 30, 2022 at 8:15
  • Because there many array so I have to use to every array and all array contains different different values Commented Apr 30, 2022 at 8:17
  • We can use fill method to solve this problem Commented Apr 30, 2022 at 8:28
  • Arrays.fill(obj, ""); Commented Apr 30, 2022 at 8:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.