By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,654 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,654 IT Pros & Developers. It's quick & easy.

Arrays in java

P: 1
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.
Feb 22 '12 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
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.parseInt or Long.parseLong to get it to the numeric type.
Feb 22 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.