Java- toCharArray() method
<pre><code>Scanner in= new Scanner(System.in);
int len=in.nextInt();
String s=in.next();
char[] ch=s.toCharArray();
System.out.println(len);
System.out.println(ch.length);
</code></pre>

<p>I have run this code snippet by providing input</p>

<pre><code>400004
//and a string of length 400004
</code></pre>

<p>The output was </p>

<pre><code>400004
8190
</code></pre>

<p>I know when we use toCharArray() then it returns a char array having same length as of the String. But here it is diffirentcult.
I am not able to understand how this is possile.
Please help me out here.</p>