Java-01-implements multiple-line input and ends with the specified end character (string) and finds the specified single character

Source: Internet
Author: User
<pre name= "code" class= "Java" >import java.util.ArrayList;
Import java.util.List;
Import Java.util.Scanner;  public class Find_az {static int a=0;
		Defining static variables is convenient for counting public static void main (string[] args) {System.out.println ("Please enter the content and end with ends");
		@SuppressWarnings ("resource") Scanner sc=new Scanner (system.in);
		String str= "";
			List<string>str_list=new arraylist<string> ()//Store data while (!str.equals ("End")) {str=sc.nextline ();		
		Str_list.add (str);
		//Multiline input end System.out.println ("Please enter the character you want to find A-Z");
		System.out.println ("");
		@SuppressWarnings ("resource") Scanner scc=new Scanner (system.in);
		String X=scc.next ();
		Char X1=x.charat (0); Converts a string type to a char type to facilitate the subsequent conversion of each string into an array a matching embarrassment would only be this stupid method for (int i=0;i< (Str_list.size ()-1); i++)//length minus one or you'll lose the end.
				Enter out {char[] S=str_list.get (i) ToCharArray ();			
				for (int i1 = 0;i1<s.length;i1++)//{if (s[i1]==x1) a++ that is used to accumulate the number character;
	} System.out.println (a); }
}/* Comment 
list< type > Only item string that can store the specified type
is string ...
String[] is an array, fixed-length, immutable
list<string> is generic, not fixed-length, variable
Not very good to achieve and a little bit of a bug shame
 * *



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.