Q:

Java's String's length function showting incorrect value

In the below code not sure why, but when we copy and paste the variable "data" then the even with the blank String it is showing length as 6. To test is please copy the same code snippet, it is working fine even if we create a new variable with same name(which is commented in below code). to test is please copy and paste code as is, as it is giving trouble only if we copy and paste it.
String data="﻿﻿﻿﻿﻿﻿"; // Copy this string variable, when we print this it gives output as 6
//String data=""; //This show's correct value as 0
System.out.println(data.length());

A:

The first data is holding 6 times &#65279 (inspect it yourself in the browser) which is a Unicode Character for a zero width no-breaking-space. The next is an actual empty String. Everything is working just fine.

