Register on the forum now to remove ALL ads + popups + get access to tons of hidden content for members only!

Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General


Thread Tools Rate Thread Display Modes
Old 08-01-2017, 03:00 AM   #1
Registered User
Join Date: Jul 2017
Posts: 15
How to reverse an integer in Java?

Hi friends,
How to reverse an integer in Java?
please suggest to know..
sonakshibhathi is offline   Reply With Quote

Old 08-02-2017, 04:53 AM   #2
Registered User
Join Date: Aug 2013
Posts: 111
Modding (%) the input int by 10 will extract off the rightmost digit. example: (1234 % 10) = 4.
Multiplying an integer by 10 will "push it left" exposing a zero to the right of that number, example: (5 * 10) = 50.
Dividing an integer by 10 will remove the rightmost digit. (
jackkodell12 is offline   Reply With Quote
Old 08-29-2017, 01:50 AM   #3
Registered User
Join Date: Aug 2014
Location: Bangalore
Posts: 3,106
You can use below code for it.
public static void reverse(int n)
int temp = 0;
int count = 0;

while(n != 0)
if(n%10 == 0)count++;
temp = temp*10 + n %10;
n /= 10;
for(int i = 0; i < count; i++)
ketul is offline   Reply With Quote
Old 03-25-2018, 10:45 PM   #4
Registered User
Join Date: Dec 2017
Location: Santa Clara, California, USA
Posts: 91
There are three ways. I know
⦁ First Method-Using Integer
⦁ Second Method-Using String
⦁ Third Method-Reverse string using StringBuffer class
Get complete info @
albertomorrison is offline   Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Do you know about Reverse SEO? christyronaldo1 General Discussion 8 Yesterday 03:56 AM
Java Jobs In Pune: A Career and Growth Perspective arshi1586 Java 1 01-19-2017 02:59 PM
How many kinds of enterprise beans do Java has? chinmay.sahoo Java 1 02-26-2016 09:45 PM
Have you ever wondered what is inside a java class file? cianfie Java 6 01-28-2015 10:09 PM
The conclusion provided by the Black Hat Java Script andrebreton2121 Search Engine Optimization 6 10-17-2012 11:06 PM

All times are GMT -7. The time now is 04:58 AM.

Powered by vBulletin Copyright © 2013 vBulletin Solutions, Inc.