I know this the very basic question. But i am very confused in it. Properly i am not getting that why we need to convert a String to CharArray. I know the work of toCharArray()
method. Only i want some real time example that why we need this method.
In my question i want also understand the relation of charArray with hashcode.
I know charArray representation:
char[] charArray ={ 'a', 'b', 'c', 'd', 'e' };
Example
public class Test {
public static void main(String args[]){
String a = "bharti";
char[] charArray = a.toCharArray();
System.out.println(charArray);
}
}
Output: bharti
For me there is no difference between output and my string bharti in variable 'a'.
Problem creation source :
Actually i want to writing a code to generate a hash password so i was reading some code from google there mostly toCharArray() method is used in it.So i didn't get we why are using this.