首页 > 其他 > 详细

acm2026

时间:2015-03-29 10:51:24      阅读:211      评论:0      收藏:0      [点我收藏+]
/**
 * 第一个字母转大写
 */
import java.util.*;


public class acm2026 {


public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String str = in.nextLine();
char[] c = new char[1];
String[] a = str.split(" ");
for (int i = 0; i < a.length; i++) {
c[0] = a[i].charAt(0);
String tp = new String(c);
/*
* replaceFirst(String regex, String replacement) 使用给定的
* replacement 替换此字符串匹配给定的正则表达式的第一个子字符串。
*/
if (i != a.length - 1)
System.out.print(a[i].replaceFirst(tp, tp.toUpperCase())
+ " ");
else
System.out.println(a[i].replaceFirst(tp, tp.toUpperCase()));
}


}
}
}


/*
 * for(int i=0; i<a.length-1; i++) { c[0] = a[i].charAt(0); String tp = new
 * String(c); System.out.print(a[i].replaceFirst(tp, tp.toUpperCase()) + " "); }
 * c[0] = a[a.length-1].charAt(0); String tp = new String(c);
 * System.out.print(a[a.length-1].replaceFirst(tp, tp.toUpperCase()));
 * System.out.println();
 */

acm2026

原文:http://blog.csdn.net/a736933735/article/details/44724711

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!