Skip to content

Instantly share code, notes, and snippets.

@gayangithub
Created January 22, 2015 05:51
Show Gist options
  • Save gayangithub/f5afd0bae2db8a92e068 to your computer and use it in GitHub Desktop.
Save gayangithub/f5afd0bae2db8a92e068 to your computer and use it in GitHub Desktop.
How To Print Integer a Integer Reverse Order Using (Basic Java**)
/**
*
* @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