请问 findChar = input.next().charAt(0);是什么意思呢?

import java.util.Scanner;

 

public class Ex3_2 {

       public static void main(String afe[]){

              String putIn = The past is gone and static. Nothing we can do will change it. Thefuture is before us and dynamic. Everything we do will affect it.

              char findChar,temp;

              int num = 0;

 

Scanner input=new Scanner(System.in);

              System.out.println("请输入要查找的字符:");

              findChar = input.next().charAt(0);

 

              for(int i = 0;i<putIn.length();i++){

                     temp = putIn.charAt(i);

                     if(temp == findChar){

                            num++;

                     }

              }

              System.out.println("字符串"+putIn+"中包含"+findChar+"个数为:"+num);

       }

      

}


越尘
浏览 4347回答 1
1回答

望远

接收键盘输入的 字符串,并且取出它的第一个字符。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java