• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

integer palindrome 'no strings'

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
howdee there,
i'm a rookie and stuck on a problem. I need to write a program without the use of strings or arrays that works out if a number is a palindrome or not. I've got the number to reverse by % and /
but need to reconstruct it so I can compare the two numbers, what i've been trying to do is to find the number of digits in the number and using a loop multiply the corresponding digits by the appropriate number, ie 10,100,1000 etc. Any help would be great.
billo 'darn tootin' bailey
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, billo!
What part of this problem are you stuck on? Feel free to post relevant example code - just be sure to surround it with the [code] and [/code] UBB Tags.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Billo, not sure if I have this straight, you have the two ints but you want to convert the new value back to the original to compare them ?? Why not just create 2 new Integer objects and use the int compareTo(Integer anotherInteger) method to do the compare for you?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, objects are nice, but a simple a == b test would likely suffice.
 
Dermot Curley
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cant beat objects
well I had to make it a bit interesting !!
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this does the trick:

Cheers, Neil
 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!