create java string with length 6 code example Example: string length in java String data = "Hello, World!"; int nameLength = data.length();