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 7523739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:53:26+00:00 2026-05-30T02:53:26+00:00

I have a string, root?param1=…&param2=…&param3=… , and I want to create a java method

  • 0

I have a string, root?param1=...&param2=...&param3=..., and I want to create a java method that will remove any duplicate params. The values will always be the same, but sometimes the params are duplicated as per the application’s function (don’t ask). Therefor,

HTTP://root?param1=value&param2=value2&param2=value2param3=value3&param3=value3&param1=value&param1=value

becomes

HTTP://root?param1=value&param2=value2&param3=value3

I’ve been out of programming too long to remember the best ways to do this but my original train of thought went something like this:

Grab each param and stick into a temp array, run through temp array and compare if array[i] equals to any other param name. If so, delete. If not, add back to a return string. At end of loop, print return string.

But that would require O(n) for the length of the URI plus O(m)! for the size of the array (m being the number of params). I think that would be pretty bad considering I’ll be running this method around 5,000x per minute for all incoming URIs. Is there a better way to go about this or an out-of-the-box java method that handles some of the overhead?

  • 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-30T02:53:28+00:00Added an answer on May 30, 2026 at 2:53 am

    You could stick the key/value pairs into a Map<String,String>. That’ll automatically take care of duplicated keys, and will be very easy to code up.

    To verify that parameters with identical keys have identical values, you could check the return value of put(): it should be either null, or equal to the value you’ve just inserted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string that looks like this /root/test/test2/tesstset-werew-1 And I want to parse
I have string that I want to chop to array of substrings of given
I have dynamic generated XML files -----Example1----- <items> <param1>aaaa</param1> <param2>bbbb</param2> <param3>cccc</param3> </items> -----Example2----- <items>
I have string like \LESSING\root\cimv2:Win32_UserAccount.Domain=LESSING,Name=Admin How to convert it to LESSING\Admin using Framework?
I have a String List with items like this Root Root/Item1 Root/Item2 Root/Item3/SubItem1 Root/Item3/SubItem2
I have string like this /c SomeText\MoreText Some Text\More Text\Lol SomeText I want to
I have string like this: G:\Projects\TestApp\TestWeb\Files\Upload\file.jpg How can I remove all text before Files
i have string stored in python variables, and i am outputting a html that
I have string looking like this: 'Toy Story..(II) (1995)' I want to split the
I have: String uri = @drawable/myresource.png; How can I load that in ImageView? this.setImageDrawable?

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.