Compare different elements of two Arrays

Source: Internet
Author: User
  1. // This program mainly describes the two simple methods for getting different elements from the two arrays.
  2. // One
  3. Public class test {
  4. /**
  5. * @ Param ARGs
  6. */
  7. Public static void main (string [] ARGs ){
  8. String [] KK = {"C", "B", ""};
  9. String [] HH = {"A", "B "};
  10. String STR = "";
  11. For (Int J = 0; j <HH. length; j ++ ){
  12. STR + = HH [J];
  13. }
  14. For (INT I = 0; I <KK. length; I ++ ){
  15. If (Str. indexof (kk [I]) =-1 ){
  16. System. Out. println (kk [I]);
  17. }
  18. }
  19. }
  20. }
  21. // Two
  22. // The following method is similar to the C Language
  23. Public class bijiao {
  24. /**
  25. * @ Param ARGs
  26. */
  27. Public static void main (string [] ARGs ){
  28. // Todo auto-generated method stub
  29. String kk [] = {"C", "A", "B "};
  30. String HH [] = {"A", "B "};
  31. String mm [] = new string [Kk. Length]; // an empty character array is opened.
  32. Mm = KK; // copy it to a temporary Array
  33. For (Int J = 0; j <KK. length; I ++)
  34. For (INT I = 0; I <KK. length; I ++)
  35. If (Mm [J] = HH [I]) // compare all data in two cycles.
  36. Mm [J] = NULL; // clear the same elements of the temporary array if the values are the same
  37. For (Int J = 0; j <length; j ++ ){
  38. If (Mm [J]! = NULL) // print out different array elements
  39. System. Out. println (kk [J]);
  40. }
  41. }

 

 

Select column from table
And then obtain them cyclically by line.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.