Chewbacca and Number

Two test cases not passing.
please check the code and help me fix the problem

code:

import java.util.*;

public class Main {

static Scanner sc = new Scanner(System.in);

public static void main(String[] args){

    long n = sc.nextLong();

    ArrayList<Integer> arr = new ArrayList<>();

    while(n > 0){

        if(n%10 <= 4 && n/10 == 0){

            arr.add((int) (n%10));

            break;

        }else if(n%10 >4 && n/10 == 0 && n%10 != 9){

            arr.add((int) (9-(n%10)));

            break;

        }else{

            if(n%10 > 4)arr.add((int) (9-n%10));

            else arr.add((int) (n%10));

        }

        n=n/10;

    }

    for(int i = arr.size()-1; i >= 0; i--){

        System.out.print(arr.get(i));

    }
}

}

99
output should be 90
Try to debug with this