Ranter
Join devRant
Do all the things like
				++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
				Sign Up
			Pipeless API
 
				From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
				Learn More
			Comments
		- 
				
				Coz 2nd one is easier for teachers and there is no type conversion. Say you want to check for palindrome after an number reversal you have to convert them to a same type.
 
 This is an assumption I also don't know the real reason for that.
- 
				
				@SPie a no. With trailing zeroes will never be a palindrome. Try passing 01210 in an int variable, it will store 1210 which will not be palindrome
- 
				
				@SPie Oh, but the question was for reverse, then yeah, a string variable will be needed to store zeroes and the no.s and.... well the second option will be messier and probably a wrong approach.
- 
				
				@sagya
 
 well it is based on ur requirement..
 
 second one has better performance than first..






Reverse number(logic)
------
First Approach :=
void reverseMethod(int n)
{
String str="";
int temp=0;
while(n>0)
{
temp=n%10;
n=n/10;
str=str+""+temp;
}
System.out.println(str);
}
-----
Second Approach :=
void reverseMethod(int n)
{
int temp=0;
int rev=0;
while(n>0)
{
temp=n%10;
n=n/10;
rev=rev*10+temp;
}
System.out.println(rev);
}
-----
why the fuck second one is recommended??
In first, at least we do not required to remember that formula.
rant
recommended approach sucks