java大小写字母相互转换

**package com.isof.dom.practice;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MyClass {
	public static void main(String [] args){
		String le = new String(args[0]);
		MyClass MM = new MyClass();
		String b =MM.aiphabetRel(le);
		System.out.println(b);
		}
	public String aiphabetRel(String a){
		Pattern pa =Pattern.compile("[A-z]");
		Matcher M = pa.matcher(a);
		Pattern p =Pattern.compile("[A-Z]");
		Matcher A = p.matcher(a);
		if(M.find()){
			if(A.find()){
				a=a.toLowerCase();
			}else{
				a=a.toUpperCase();
			}
			
		}else{
			a="请输入字母";
		}
		return a;
		
	}

}**

猜你喜欢

转载自blog.csdn.net/Jack_HuzZ/article/details/83753977
今日推荐