If
char [] a = {'x','y','x'};
I need an
int [] b={5,3,5};
It is clear that 'x' correspond to 5 and 'y' corresponds to 3.
I tried to get this way through JAVA code:
public static void main(String[] args) {
char [] a= {'x','y','x'};
int[] b ={};
for(int i=0; i<a.length; i++){
if( a[i]=='x'){
b[i]=3;
} else {
b[i]=5;
}
System.out.println(b[i]);
}
}}
but failed. I need help.