『壹』 tochararray 在java中是什么意思

转为字符数组,是string类的方法

『贰』 java 的toCharArray

toCharArray是将String的每一个字符拆分出来放到一个char数组里
String里的11会拆分成 1、1

『叁』 java char[] c = a.toCharArray(); char v = a.charAt(i); 这两种解法有什么区别

你好,首先你会发现这两个方法的返回值不同,前者是字符数组,后者是字符。下面通过一个例子来分析这两个方法:
a = "abcd" ;
a.toCharArray() ; 的返回值就是{'a','b','c','d'} ;
a.charAt(i) 注意i的取值是0~a.length-1,这里可以分别取0 1 2 3对应的返回值分别为:a b c d。
明白了吧。

『肆』 java中的toCharArray()方法是啥意思

意思是把别的数据转换成字符数组吧 比如内说字符串容
public class ReverseString {

public static void main (String args[]){
String originalString;
String resultString = "";

originalString = JOptionPane.showInputDialog("Please input a String: ");

char[] charArray = originalString.toCharArray();

for (int i=charArray.length-1; i>=0; i--){
resultString += charArray[i];
}

JOptionPane.showMessageDialog(null, resultString, "Reverse String", JOptionPane.INFORMATION_MESSAGE);
}
}

『伍』 谁知道java中 toCharArray()方法的原代码

/**
* Converts this string to a new character array.
*
* @return a newly allocated character array whose length is the length
* of this string and whose contents are initialized to contain
* the character sequence represented by this string.
*/
public char[] toCharArray() {
char result[] = new char[count];
getChars(0, count, result, 0);
return result;
}

/**
* Copies characters from this string into the destination character
* array.
* <p>
* The first character to be copied is at index <code>srcBegin</code>;
* the last character to be copied is at index <code>srcEnd-1</code>
* (thus the total number of characters to be copied is
* <code>srcEnd-srcBegin</code>). The characters are copied into the
* subarray of <code>dst</code> starting at index <code>dstBegin</code>
* and ending at index:
* <p><blockquote><pre>
* dstbegin + (srcEnd-srcBegin) - 1
* </pre></blockquote>
*
* @param srcBegin index of the first character in the string
* to .
* @param srcEnd index after the last character in the string
* to .
* @param dst the destination array.
* @param dstBegin the start offset in the destination array.
* @exception IndexOutOfBoundsException If any of the following
* is true:
* <ul><li><code>srcBegin</code> is negative.
* <li><code>srcBegin</code> is greater than <code>srcEnd</code>
* <li><code>srcEnd</code> is greater than the length of this
* string
* <li><code>dstBegin</code> is negative
* <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than
* <code>dst.length</code></ul>
*/
public void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) {
if (srcBegin < 0) {
throw new (srcBegin);
}
if (srcEnd > count) {
throw new (srcEnd);
}
if (srcBegin > srcEnd) {
throw new (srcEnd - srcBegin);
}
System.array(value, offset + srcBegin, dst, dstBegin,
srcEnd - srcBegin);
}

『陆』 JAVA中char a[]=s.toCharArray();为什么a[0]=a[0]^'a';要写成a[0]=(char)(a[0]^'a');

那是因为 ^ 这个操作符是操作两个数值的,计算机只有把它左右的两个变量看作两个整数。因此你异或了以后的结果当然是个整数,你需要手动把它再转成字符

『柒』 请问java中toCharArray()方法是做什么用的

toCharArray()方法:有的时候根据需要char类型的数组
但你实际的数据是String类型的
所以提供了将String类型参数转化为char[]类型参数的方法. Math.pow()这个~简单讲~Math.pow(double a, double b)
是求a的b次方的

『捌』 java中toCharArray方法是做什么用的

toCharArray的方法:有的时候根据需要char类型的数组。将字符串转换成字符数组,便于对每一个字符进行单独操作,比如加密,这仅用来增加灵活性,字符串也有用来访问单个字符的方法。Math类中的方法都是静态的,不用声明对象,直接用类名Math调用。所以提供了将String类型参数转化为char[]类型参数的方法. Math.pow()这个简单来讲~Math.pow(double a, double b)是求a的b次方的

『玖』 java中如何取toCharArray()中的数据

使用字符数组,如下:
String s = "abc";
char c[] = s.toCharArray();

『拾』 java tochararray 问题 求解

toCharArrays直接就转换成数据了,不需要再循环调用。

char [3] r="hello";不可以,这样char[] r = "hello".toCharArrays();