This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
You would have to set up a new array as a recipient, with the requisite size, and use a for loop to iterate the arrays and copy the values from source array to target array. At least that's how you would do it for a class exercise.
In real life you would use the System.arraycopy() method.
BTW: Does your declaration of a 30-member array actually compile? You are declaring it with 30 members and initialising it with 26.
Joined: Oct 13, 2005
Thank you for replying, Rohan Kolbhar, but it is not the policy of the Ranch to give out simple answers like that. And what you posted doesn't actually achieve what is required. Suggest you edit your post and remove the answer.
I would do it with a int arrays, using the / and % operators, but a lot of beginners would see that as very complicated programming.
Joined: Aug 18, 2006
thanks for acquainting me with this policy. I have just given an overall idea of the logic with code.I feel that this forum is for beginners.So most of the programmers have good logic but problems arise during coding.
Unfortunately, while some people asking for solutions do just need a bit of help with a solution they're working on, there are far too many people who just want a ready-made answer for their homework or job. We don't want to give them those ready-made answers, because they will progress in their courses or jobs without really gaining the necessary skills. And, one day, you or I might have to work with them...
So, by all means, help out, but do so in such a way that the person you're helping learns from the experience.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: Oct 13, 2005
I first came across this problem this morning and it is now nearly 3pm. The more I think about it, the more difficult it appears to be to get an array into the format Darren appears to require. I can see how it can be done, but it by no means an easy problem to give beginners.