How to include the case when the first digit in the no is 9,so that our new no doesnt start with 0

import java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner sc=new Scanner(System.in);
String x=sc.nextLine();
String ans="";
int n=x.length();
int[] arr=new int[n];
for(int i=0;i<n;i++)
{
arr[i]=x.charAt(i)-48;
if(arr[i]<=4){
ans=ans+arr[i];

		}
		else if (arr[i]>=5 && arr[i]<=9){
			arr[i]=9-arr[i];
			ans=ans+arr[i];
		}
	}
	System.out.print(ans);
}

}

@vaibhavvishal98,

        if(arr[i] == 9 && (i==0) == 0){
         //do nothing