Chewbacca and b=number what is mistake in my code

import java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner sc=new Scanner(System.in);
int i;long x;
x=sc.nextLong();
String s=Long.toString(x);String q="";
for(i=0;i<s.length();i++)
{
char a=s.charAt(i);
if(a==‘9’&&i==0)
q=q+“9”;
else if(a>(char)(‘9’-a))
q=q+Character.toString(a);
else if() {
a=(char)(‘9’-a);
q=q+Character.toString(a);
}

	}
     System.out.println(q);
}

}

Hi @rahul.parasmani,
The way you are type casting is logically wrong.‘9’-a is actuall subtracting ascii value of 9 from ascii value of a and then the typecast finally returns the symbol with ascii value which can after subtracting ascii value of 9 from ascii value of a … Therefore that value is always less than a. However the correct code is at this link.https://ide.codingblocks.com/s/156085

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.