• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 645
  • Last Modified:

Using API

ok so i found a method on that site which is  

java.util.Vector intersection(java.util.Vector v1, java.util.Vector v2, boolean sorted)
          Returns the intersection of two vector.

on this website

how do i call the intersection function... i keep getting undefined...what do i have to do?
  • 2
2 Solutions
Hi there

the documentation what you have seen is developed by some other person and is not a part of sun API.

This simple solution will help you to get the intersection of two lists

public static java.util.Vector intersection  (java.util.Vector a,  java.util.Vector b)
            java.util.HashSet c= new java.util.HashSet();
            for(int i=0;i<a.size();i+=1)
                  for(int j=0;j<b.size();j++)
            return new java.util.Vector(c);


calling the above code,,,,
               java.util.Vector a=new java.util.Vector();

            java.util.Vector b=new java.util.Vector();
            java.util.Vector c=      intersection(a,b) ;
Or use Apache Commons Collections, which have methods for intersection, union, etc
Your API is just the same

VectorUtils util = new VectorUtils();
Vector intersection = util.intersection(v1, v2, false); // or true in case the vectors are sorted
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now