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"];
5
  • 1
    I know lots of answers on the way, but what you have tried so far ? Hint : String.valuOf(intValue); Commented Feb 6, 2014 at 12:04
  • Please use the search before you ask a question. The answer to your question is the top answer for "java array to string" on Google. Commented Feb 6, 2014 at 12:05
  • @TwoThe i have tried okey and was not getting ans that is why i out that. Commented Feb 6, 2014 at 12:19
  • Ya i have tried. @sᴜʀᴇsʜᴀᴛᴛᴀ Commented Feb 6, 2014 at 12:19
  • From next time on words do not forget to add tried code. Anyways you have multiple answers and duplicated questions. Commented Feb 6, 2014 at 12:20

2 Answers 2

0

try this

String res = Arrays.toString(a).replaceAll("(\\d+)", "\"$1\"")
Sign up to request clarification or add additional context in comments.

1 Comment

its not working dude its giving still that complex Structure i dont want it.
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]);
}

1 Comment

Its not working its giving String formate like this.@88174c i need String values..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.