一种将英文文章字符串每个单词首字母转成大写字母的方法
2016-11-19 10:47
423 查看
import java.util.Arrays;
public class newexercise3 {
public static void main(String[] args) {
String str =new String("If you were a teardrop;In my eye,For fear of losing you,I would never cry.And if the golden sun,Should cease to shine its light,Just one smile from you,Would make my whole world bright.");
System.out.println(str);
byte []by=str.getBytes();
for(int i=0;i<by.length-1;i++){
switch(by[i]){
case 32:
case 33:
case 46:
case 59:
case 63:
if(by[i+1]>=65&&by[i+1]<=90){
continue;
}else{
by[i+1]=(byte) (by[i+1]-32);
num++;
}
}
}
String s =new String(by);
System.out.println(s);
}
}
public class newexercise3 {
public static void main(String[] args) {
String str =new String("If you were a teardrop;In my eye,For fear of losing you,I would never cry.And if the golden sun,Should cease to shine its light,Just one smile from you,Would make my whole world bright.");
System.out.println(str);
byte []by=str.getBytes();
for(int i=0;i<by.length-1;i++){
switch(by[i]){
case 32:
case 33:
case 46:
case 59:
case 63:
if(by[i+1]>=65&&by[i+1]<=90){
continue;
}else{
by[i+1]=(byte) (by[i+1]-32);
num++;
}
}
}
String s =new String(by);
System.out.println(s);
}
}
相关文章推荐
- 使用JavaScript 将字符串中由空格隔开的每个单词首字母大写,写出通用方法。
- 输入一个英文句子,将每个单词的第一个字母改成大写字母。
- 给出一句英文句子: "let there be light" 得到一个新的字符串,每个单词的首字母都转换为大写
- 分享一个.NET(C#)按指定字母个数截断英文字符串的方法–提供枚举选项,可保留完整单词
- 编写一个程序,输入一串不超过60个字符组成的且不包含换行符的字符串,将字符串中的A到Z的字母按英文字典字母顺序重新排列,排列后的单词的长度要与原始句子中的长度相同,并且要求只对A到Z的字母重新排列,其
- php:ucwords() --将字符串中每个单词的首字母转换为大写
- 将一段英文每个单词首字母大写
- 一种Playfair密码变种加密方法如下:首先选择一个密钥单词(称为pair)(字母不重复,且都为小写字母),然后与字母表中其他字母一起填入至一个5x5的方阵中,填入方法如下:
- 让字符串中每个单词的首字母大写
- php实现字符串首字母大写和单词首字母大写的方法
- 将输入字符串中每个单词的首字母变成大写
- 将字符串中的每个单词顺序进行颠倒,单词还是原来的单词,字母顺序不发生变化
- 将字符串中的每个单词顺序进行颠倒,单词还是原来的单词,字母顺序不发生变化,将字符串中的空格用 代替
- 字符串每个单词首字母大写
- 67.读入字符串把每个单词开始的字母大写
- Java 写一个方法判断一个字符串是否对称 "asdfgasdfg"、编写一个程序,将下面的一段文本中的各个单词的字母顺序翻转,
- 【java】统计一篇英文文章每个字母出现的次数
- 有一行字符,要求将每个单词中的第一个字母改成大写字母
- 请编写一个方法,将字符串中的空格全部替换为“%20”。假定该字符串有足够的空间存放新增的字符,并且知道字符串的真实长度(小于等于1000),同时保证字符串由大小写的英文字母组成
- 请编写一个方法,将字符串中的空格全部替换为“ ”。假定该字符串有足够的空间存放新增的字符,并且知道字符串的真实长度(小于等于1000),同时保证字符串由大小写的英文字母组成。