On recent JVM targets, strings are stored as ISO-8859-1 (one byte per character) if its content consists solely of characters in that character set. Otherwise, it is stored as UTF-16 (mostly two bytes per character, or more if using certain characters such as emojis). However, you said that you want to check the shallow size of the data class, so the string representation is irrelevant. See
https://www.baeldung.com/java-size-of-object for some more info.