Junilu Lacar wrote:Then let me be even more blunt with you. Not formatting your code, knowing that it's terrible, and not doing anything about it is very INCONSIDERATE of other people who would like to help you. That's like going into someone's house with dirty shoes, tracking mud all over the living room, and saying "I know my shoes are dirty but I have no time to think about you, just help me get this mud off." If I were the house owner, I would kick you out
Paul Clapham wrote:
John Sing wrote:and here is the error I am getting
"java.lang.ArrayIndexOutOfBoundsException: 998
at numberPicker.main(numberPicker.java:42)
That tells you several things:
1. You tried to access an array outside of its actual bounds.
2. You tried to access element 998.
3. You did that at line 42, which is in a method named "main".
So you should look at that line and find out why you are trying to access element 998 of an array which isn't that big.
Junilu Lacar wrote:Since you're dealing with integer values, you can just use % and / (integer division) to reverse the number. If the reverse of a number and the original number are the same then it's a palindromic number.
For example, the reverse of 89:
89 % 10 = 9
89 / 10 = 8
9 * 10 = 90
90 + 8 = 98
98 != 89 therefore 89 is not a palindrome
77 % 10 = 7
77 / 10 = 7
7 * 10 = 70
70 + 7 = 77
77 == 77 therefore 77 is a palindrome
---
Exercise for you is to generalize this and put it into a loop.
I would break the problem down into two parts:
1 - find the reverse of a number
2 - find the largest palindromic number that is the product of X-digit numbers