I need to replace a word in array Eg: if string[]a = [1,2,3] as input string []b= [a,b,c]
If I get the input in array has 3,2,1 it should print c,b,a. Can anyone please help me
I need to replace a word in array Eg: if string[]a = [1,2,3] as input string []b= [a,b,c]
If I get the input in array has 3,2,1 it should print c,b,a. Can anyone please help me
Use map like this to get that
private static void getArray(int[] num) {
TreeMap<Integer, Character> tMap = new TreeMap<>();
char c = 0;
int i = 1;
for (c = 'a'; c <= 'z'; c++) {
tMap.put(i, c);
i++;
}
System.out.println("Map = " + tMap);
for (int k = 0; k < num.length; k++) {
System.out.println("Map by key = " + tMap.get(num[k]));
}
}
This will give following result:
input : int[] num = {4,5,6};
output : Map = {1=a, 2=b, 3=c, 4=d, 5=e, 6=f, 7=g, 8=h, 9=i, 10=j, 11=k, 12=l, 13=m, 14=n, 15=o, 16=p, 17=q, 18=r, 19=s, 20=t, 21=u, 22=v, 23=w, 24=x, 25=y, 26=z}
Map by key = d
Map by key = e
Map by key = f