Those years, learn together Java 6-4

Source: Internet
Author: User

/**

* 6-4

* Create two String objects using a String class,

* Find all the same characters for two strings

* and output it on the screen

**/

Import Java.util.arraylist;public class Test{public static void Main (string[] args) {String str1 = "My name is Xingfei Du" ; String str2 = "I like programming."; arraylist<character> array = new arraylist<character> ();/* Find the same all characters */for (int i = 0; i < str1.length (); i++  ) for (int j = 0; J < Str2.length (), j + +) if (Str1.charat (i) = = Str2.charat (j)) Array.add (Str1.charat (i));/* filter out duplicate characters */for (int l = 0; l < array.size (); l++) for (int m = 0; m < array.size (); m++) if (Array.get (L) ==array.get (m)) {Array.remov E (Array.get (m));} for (int i = 0; i < array.size (); i++) System.out.print (Array.get (i) + "");}}


Those years, learned Java 6-4

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.