Created
January 22, 2015 05:51
-
-
Save gayangithub/f5afd0bae2db8a92e068 to your computer and use it in GitHub Desktop.
How To Print Integer a Integer Reverse Order Using (Basic Java**)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @author Gayan | |
*/ | |
public class ReverseInt { | |
private static int count=1; | |
private static boolean found=false; | |
public static void getnumberofdegits(int number){ | |
int i=1; | |
while(!found){ | |
if(number<i*10){ | |
found=true; | |
break; | |
} | |
else{ | |
i=i*10; | |
count++; | |
} | |
} | |
} | |
public static void getreverse(int number){ | |
getnumberofdegits(number); | |
int modulevalue=10; | |
int devider=1; | |
int[] array = new int [count]; | |
for(int i=0;i<count;i++){ | |
array[i]=(number%modulevalue)/devider; | |
modulevalue=modulevalue*10; | |
devider=devider*10; | |
} | |
int printcount=0; | |
while(printcount<count){ | |
System.out.print(array[printcount]); | |
printcount++; | |
} | |
} | |
public static void main(String [] args){ | |
int x=12345678; | |
ReverseInt.getreverse(x); | |
System.out.println(""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment