Friday 16 September 2016

logic for reverse number in java

    int reverse = 0;
        int remainder = 0;
        do{
            remainder = number%10;
            reverse = reverse*10 + remainder;
            number = number/10;
         
        }while(number > 0);
     
        return reverse;
    }




  • Step 1: Take the remainder after dividing the number by 10. In this way, we can get last digit of the number.
  • Step 2: Store last digit in a temporary variable ‘revNum’. If there is some value in ‘revNum’, multiply that with 10 so that the earlier digits will be moved left, and then add the remainder (new last digit).
  • Step 3: Divide the original number with 10, and if the number does not become zero then repeat the above steps so that we can get each digit from last one by one.

ADb command for installation and unstallation apk

install

adb install "apk path"

uninstall

adb uninstall "packagename"