1个回答
展开全部
import java.util.*;
public class CharacterTest {
static Scanner sc=new Scanner(System.in);
public static void main(String[] args) {
char[] chs=new char[4];
String str="";
for(int i=0;i<chs.length;i++){
System.out.println("输入第"+(i+1)+"个字符回车结束!");
chs[i]=sc.nextLine().charAt(0);
String s="";
char tem=chs[i];
if(Character.isLetterOrDigit(tem))
if(Character.isLetter(tem))
s+=Character.isLowerCase(tem)?Character.toUpperCase(tem):Character.toLowerCase(tem);
else
s+=tem;
else
s+="oter";
str+=s+" ";
}
System.out.println("输入结果:"+Arrays.toString(chs));
System.out.println("\n目标输出:"+str);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询