小编jav*_*vip的帖子

如何使用charAt方法将大写转换为小写?

我需要创建一个函数,使用该charAt方法将所有大写字符设置为小写.我曾尝试使用类型转换将int值更改为char但之后丢失了.

/********************************************************************************
  This function will calculate the integer average of characters in the array
********************************************************************************/
public static void lowerCase(char[] letter) {
    char mean;
    mean = (char) ((int) ch + 32);
}
Run Code Online (Sandbox Code Playgroud)

java

6
推荐指数
1
解决办法
4万
查看次数

将阵列向右移动 - 作业

这是我到目前为止,但是当我运行它时,我得到Java不匹配错误.这是我的阵列:

char[] letters = {'A', 'B' , 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'};


/********************************************************************************
    shiftRight() will move the contents of the array one slot to the right
********************************************************************************/
public static void shiftRight( char [] letters )
{
    char last = letters[letters.length-1];          // save off first element

    // shift right
    for( int index =letters.length-1; index >= 0 ; index-- )
        letters[index+1] = letters [index];

    // wrap last element into first slot
    letters[0] = last;
    System.out.print("\nshifted Array: " );
}
Run Code Online (Sandbox Code Playgroud)

java arrays

3
推荐指数
1
解决办法
5万
查看次数

标签 统计

java ×2

arrays ×1