0

Hello i want to convert int Array into Required Format.

i have int array and how to convert it ? i want this String format

int a = [1,2,3,4]
list a = [1,2,3,4]
String = ["1","2","3"];
Kishan Bheemajiyani
  • 3,429
  • 5
  • 34
  • 68

2 Answers2

0

You can iterate over int[] and convert to String[].

int[] a = new int[]{1, 2, 3, 4};
String[] convertedArr = new String[a.length];
for (int i = 0; i < a.length; i++) {
  convertedArr[i] = String.valueOf(a[i]);
}
TwoThe
  • 13,879
  • 6
  • 30
  • 54
Ruchira Gayan Ranaweera
  • 34,993
  • 17
  • 75
  • 115
0

try this

String res = Arrays.toString(a).replaceAll("(\\d+)", "\"$1\"")
Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275