Arrays in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sara Julie
    New Member
    • Feb 2012
    • 1

    Arrays in java

    How to convert all the elements of an array into a single number? For example if an array a={1,1,2,0}. I need to convert the elements as b=1120. How can I do this. If anyone knows please answer me.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Initialize a String to the empty string "";
    Then loop through each value of the array adding it to the string.
    After the loop is done you'll have the number in a string as "1120".
    Then use Integer.parseIn t or Long.parseLong to get it to the numeric type.

    Comment

    Working...