I know this is the easiest question. But I am very confused. That's right, I do not get this , why do we need to convert String to CharArray . I know the operation of the toCharArray()
method. Only I need a real-time example of why we need this method. In my question, I also want to understand the relation of charArray with hashcode.
I know the charArray view:
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 and my bharti string in the variable 'a .
Source of the problem :
Actually, I want to write code to generate a hash password, so I read some code from google, the toCharArray () method is mainly used there. Therefore, I did not understand why this is used.
source share