i am developing program for union and intersection of two strings in android, i also calculate number of character in union as well intersect results individually?the results values (union&intersect) should pass to native calculator and the result will shown in calculator?
i have to pass the that result data to native calculator?
examle:i have two strings
sunday, monday
the union is: sundaymo ,the length of result union string is: 8 the intersection is : nday ,the length of result intersection string is: 4
the sum of union and intersection is : 8+4=12 ; the values 8 and 4 should pass to native calculator ,the result should be shown in native calculator .
how should i do please provide code for me please answer to me
String s1 = new String("10201");
String s2 = new String("01341");
//intersect
HashSet<Character> h1 = new HashSet<Character>(), h2 = new HashSet<Character>();
for(int i = 0; i < s1.length(); i++)
{
h1.add(s1.charAt(i));
}
for(int i = 0; i < s2.length(); i++)
{
h2.add(s2.charAt(i));
}
//union
h1.addAll(h2);
//intersect
h1.retainAll(h2);
//
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.