Java三种判断字母大小写的方法
2016-06-10 11:43
441 查看
public class AaNum { public static void main(String[] args) { String s = new String("12HMa&%$k#d_34H3aH"); int max = 0; int min = 0; int other = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z') { max++; } else if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z') { min++; } else other++; } System.out.println("max:" + max + "\nmin:" + min + "\nother:" + other); max = 0; min = 0; other = 0; for (int i = 0; i < s.length(); i++) { if (Character.isUpperCase(s.charAt(i)) == true) { max++; } else if (Character.isLowerCase(s.charAt(i)) == true) { min++; } else other++; } System.out.println("max:" + max + "\nmin:" + min + "\nother:" + other); max = 0; min = 0; other = 0; String sL = "abcdefghijklmnopqrstuvwxyz"; String sU = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for (int i = 0; i < s.length(); i++) { if (sL.indexOf(s.charAt(i)) != -1) { max++; } else if (sU.indexOf(s.charAt(i)) != -1) { min++; } else other++; } System.out.println("max:" + max + "\nmin:" + min + "\nother:" + other); } }
相关文章推荐
- java对世界各个时区(TimeZone)的通用转换处理方法(转载)
- java-注解annotation
- java-模拟tomcat服务器
- java-用HttpURLConnection发送Http请求.
- java-WEB中的监听器Lisener
- Android IPC进程间通讯机制
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- 介绍一款信息管理系统的开源框架---jeecg
- 聚类算法之kmeans算法java版本
- java实现 PageRank算法
- PropertyChangeListener简单理解
- c++11 + SDL2 + ffmpeg +OpenAL + java = Android播放器
- 插入排序
- 冒泡排序
- 堆排序
- 快速排序
- 二叉查找树