Results 1 to 4 of 4
- 11-24-2011, 07:42 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 35
- Rep Power
- 0
- 11-24-2011, 08:24 PM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
Re: searching one elements of array into another array???
The collection to use here is a Set. Put the first collection into a set, removeAll() the elements of the second collection and the difference you are left with is what you are trying to calculate.
The Set Interface in Oracle's Tutorial describes the usage of this collection - including a description of the very problem you pose in the section "Set Interface Bulk Operations".
- 11-24-2011, 08:34 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
Re: searching one elements of array into another array???
Just because I'm feeling a bit obnoxious tonight:
kind regards,Java Code:public class T { public static void main(String[] args) { char[] first= { 'A','B','D','E' }; char[] second = { 'C','E','A' }; String s1= new String(first); String s2= new String(second); System.out.println(s2.replaceAll("["+s1+"]", "")); } }
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 11-25-2011, 12:38 AM #4
Member
- Join Date
- Sep 2009
- Posts
- 35
- Rep Power
- 0
Similar Threads
-
Searching array elements for keywords
By Nanomech in forum New To JavaReplies: 2Last Post: 08-13-2011, 01:46 PM -
Searching through Array of Objects
By coopc in forum New To JavaReplies: 6Last Post: 04-26-2011, 03:32 PM -
searching for a name in my 2d array and printing the info that is on its row
By ziongio in forum New To JavaReplies: 3Last Post: 03-15-2011, 12:24 PM -
searching char array with another char array for full word matches
By karunabdc in forum New To JavaReplies: 2Last Post: 03-08-2011, 06:20 AM -
Searching and comparing Array elements
By jmanswrd in forum New To JavaReplies: 5Last Post: 02-15-2011, 06:06 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks