Now i have included corner case 0 as u said but its still showing 0000 in output------------
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt(),count = 0;
while(n>0){
n = n /10; count++;
}
int arr[] = new int[count];
int m = arr.length -1;
while(n>0){
int d = n%10;
arr[m] = d;
n = n / 10;
m–;
}
for(int i = 0;i<arr.length;i++){
if(arr[i] == 0){
}
else if(9-arr[i]<arr[i]){
arr[i] = 9-arr[i];
}
}
for(int s: arr){
System.out.print(s);
}
}
}