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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:26:16+00:00 2026-05-26T22:26:16+00:00

RetainAll method function is in java what is alternative method in objective-C sample code

  • 0

RetainAll method function is in java what is alternative method in objective-C

sample code in java

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class MainClass {
  public static void main(String args[]) {
    String orig[] = { "1st", "2nd", "3rd", "4th", "5th", "1st", "2nd", "3rd",
        "4th", "5th" };
    String act[] = { "2nd", "3rd", "6th" };
    List origList = new ArrayList(Arrays.asList(orig));
    List actList = Arrays.asList(act);

    System.out.println(origList.retainAll(actList));
    System.out.println(origList);
  }
}

The out put which gives 2nd 3rd 2nd 3rd

  • 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-26T22:26:16+00:00Added an answer on May 26, 2026 at 10:26 pm

    There isn’t a simple method for this in NSArray, but you can achieve the same effect with a predicate:

    NSArray *intersectionOfArrays = [orig filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF IN %@", act]];
    

    As Tim Dean points out, this is normally an operation on sets rather than arrays, and NSSet does have methods for doing it. If your application actually could use a set here, that’s probably the best approach instead of shoehorning set behavior into an array. But if you need to keep the original ordering, you’ll have to do it with a predicate.

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

Sidebar

Related Questions

In Java, the containsAll and retainAll in the AbstractCollection class explicitly state that cardinality
I am trying to create a class say MyStack that would implement a java.util.collections
By looking at the code of Collections class, i got to know that when
I'm implementing List interface to a class which stores data in a <T> type
I'm trying to complete the puzzle. __strong is the default for all Objective-C retainable
In Android, when the screen orientation changes (between landscape and portrait) the onCreate method
java.lang.UnsupportedOperationException: This operation is not supported on Query Results at org.datanucleus.store.query.AbstractQueryResult.contains(AbstractQueryResult.java:250) at java.util.AbstractCollection.retainAll(AbstractCollection.java:369) at
The old value/reference things. Im getting ConcurrentModificationException for this adaptation of the Bron-Kerbosch. public
I have a div that looks like this <div class=listItem jrFeatured> I want it
I am using eclipse on mac to do my java coding. Now i need

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.