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,241
  • 5
  • 30
  • 62

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,319
  • 6
  • 28
  • 52
Ruchira Gayan Ranaweera
  • 33,712
  • 16
  • 72
  • 110
0

try this

String res = Arrays.toString(a).replaceAll("(\\d+)", "\"$1\"")
Evgeniy Dorofeev
  • 129,181
  • 28
  • 195
  • 266