I want to read a String sentence from a Textfield and compare each letter in the String to my list of already made strings which look like this:
A = 123f;
B = 221d;
H = 2333gg;
And so on..
My question is: how can i read my message as individual strings lets say this is the message: "Hello World"
i want to be able to compare every word to my strings that i have made:
so “Hello World” it would compare the first letter “H” and it would make it into what i defined “H” to be, So it would output in a JLabel or anything else as 2333gg.
Thank you in advance!
I think you need to store your letters (A = …, B = …, H = …) into a
Map, then you iterate through the input letters (that you can get from the input string usingtoCharArray()), and if theMapcontains the letter as a key, you output the corresponding value. Something like this: