我需要创建一个函数,使用该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不匹配错误.这是我的阵列:
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)