Java字符判断的小例子

代码入下:

代码如下:
import java.io.*; public class Practice {     public static void main(String[] args) {         // TODO Auto-generated method stub         BufferedReader buf;         buf=new BufferedReader(new InputStreamReader(System.in));                try        {             String str=buf.readLine();             for(int i=0;i<str.length();i++){                  char ch = str.charAt(i);                 //System.out.println(ch);                 if(!Character.isLetter(ch))                 {                     System.out.println("此字符不是字母");                 }                 else if(Character.isLetter(ch))                 {                     if (!Character.isLowerCase(ch))                     {                         System.out.println("此字符是大写字母");                     }                     else if (Character.isLowerCase(ch))                     {                         System.out.println("此字符是小写字母");                     }                 }             }         }         catch(Exception e)         {         }     } }

效果如图所示:

以上是 Java字符判断的小例子 的全部内容, 来源链接: utcz.com/p/207793.html

回到顶部