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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:58:02+00:00 2026-06-06T00:58:02+00:00

I have the following class: class A { String s; } And the following

  • 0

I have the following class:

class A {
    String s;
}

And the following list of lists of class A objects:

[{1s, 3f, 46h}, {333s, 67b, 1d, 67m, 67h}, {3a, 3x}, {34n, 22o, 34s},
 {40f, 22x, 4m}... and so on]

All I need is to iterate through this list, get the results and push into another output arrayList. Now what would be included in the result arrayList:

1. Just skip those elements from the above input arrayList
   which have more than one String with same prefix(only the last character
   is the suffix here which will always be a single character alphabet; not digit).
   For example: from the above input arrayList the first element({1s, 3f, 46h}) 
   won't be skipped and will be pushed into the output arrayList
   as it doesn't have any String with the same prefix; as 1, 3 and 46 are different.
   But 2nd, 3rd and 4th elements will be skipped as they have matches
   (three prefixes with same 67 in 2nd element, two prefixes with same 3 in 3rd element
   and two prefixes with same 34 in 4th element).

   So, for the above input arrayList the output arrayList will be:
   [{1s, 3f, 46h}, {40f, 22x, 4m}]

Can anybody suggest me how can I do the above job in an easy and efficient way. Please give
some sample code if possible.

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-06T00:58:04+00:00Added an answer on June 6, 2026 at 12:58 am

    So if I were writing tests for this, I would see that one of the things I need is to be able to determine the prefix. Given an A with string “55p”, the prefix should be “55”. Write a test for that. Where does the prefix method belong? Probably in the A class itself. It should look something like:

    public String prefix() {
        return ...;
    }
    

    Once you have that method, it’s easy to iterate over all the A’s in a list and determine if any of them have the same prefix.

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

Sidebar

Related Questions

I have the following code: class Employee { friend string FindAddr( list<Employee> lst,string name
I have the following class structure: class Organization { string Name; List<User> users; List<Organization>
I have the following C# class: public class SomeClass{ public string Name; public List<SomeClass>
Given that I have the following WCF service: class LookUpService { public List<County> GetCounties(string
I have the following code class Program { static void Main(string[] args) { List<A>
I have an object with the following hierarchy class Account string username List Delegations
So I have created the following script: class spImageUpload() { private static System.Collections.Generic.List<string> keywords;
I have a List of objects with this implementation: class Locations { public string
Lets say I have a generic list of the the following objects: public class
I have the following business objects: public class ItemCategoryBO { public string ItemCategory {

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.