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

  • SEARCH
  • Home
  • 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 8736885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:23:41+00:00 2026-06-13T10:23:41+00:00

So I am not really familiar with the java String methods and I am

  • 0

So I am not really familiar with the java String methods and I am not sure if there’s an easy way to do this. I have a String which contains couple of values delimited with “:” and each couple is separated from the others by another delimiter “,”. For example:

AA:BB,CC:DD,XX:YY,EE:FF

The mapping is “from” and “to” value. Based on a condition, I get the “from” value, let’s take for example “XX”, and I want to retrieve the “to” value in this case “YY”.

I am not really sure how to do it. Any help will be appreciated.

Thanks 🙂

  • 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-06-13T10:23:43+00:00Added an answer on June 13, 2026 at 10:23 am

    You can convert the string into a map:

    String[] items = string.split(",");
    Map<String, String> map = new HashMap<String, String>();
    for (String item : items) {
        String[] split = item.split(":");
        map.put(split[0], split[1]);
    }
    

    Basically, you split the string twice. First, you break it into the individual key-value pairs by splitting it with split(","), then loop through all of these pairs. We split each pair once again, this time by the colon, then store the value in a key-value map which maps strings keys to string values.

    You can then read a value from the map like so:

    map.get(key);
    

    For example, using your example data:

    System.out.println(map.get("CC")); // prints "DD"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not really familiar with creating generic methods, so I thought I'd put this
i'm really not very familiar with CSS and HTMl so take it easy with
Not really too sure how to word this question, therefore if you don't particularly
Not really sure how to phrase this other than by example.. Given... DATABASES =
I not really sure how to describe correctly my problem. My layout contains a
I'm not really sure how to ask this question, but I'll do my best.
I'm writing a java binding for a C code and I'm not really familiar
I'm having an issue with flash, which I am not really familiar with. I'm
Im not really familiar with how this works in JSP but in the main.jsp
I am not really familiar with Joomla but I have been tasked with writing

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.