Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4050758
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:06:35+00:00 2026-05-20T14:06:35+00:00

I want to read a String sentence from a Textfield and compare each letter

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:06:35+00:00Added an answer on May 20, 2026 at 2:06 pm

    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 using toCharArray()), and if the Map contains the letter as a key, you output the corresponding value. Something like this:

    Map<Character, String> lettersMap = new HashMap<Character, String>();
    lettersMap.put(Character.valueOf('A'), "123f");
    lettersMap.put(Character.valueOf('B'), "221d");
    lettersMap.put(Character.valueOf('H'), "2333gg");
    
    String input = "Hello world";
    StringBuffer sb = new StringBuffer();
    char[] inputLetters = input.toCharArray();
    for (int i = 0; i < inputLetters.length; i++) {
        Character letter = Character.valueOf(inputLetters[i]);
        if (lettersMap.containsKey(letter))
            sb.append(lettersMap.get(letter));
    }
    System.out.println(sb.toString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to read a String character by character which is already in an
I want to read UTF-8 strings from a server that I have control of,
I want to read issuer String from user's public key with Bouncy Castle. Is
I want to read the text from the localizable.strings file. I am collecting the
I want to read string from standart input and output it in on console.
If I want to read in a string of arbitrary length from the command
Hi I want read from a hung text file data directly to a string
What I want to do is read a line from text file which contains
I want to read the string after delimiter from a text file in Objective-C.i'm
I want to read a string from the character , to the very end.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.