I'm not 100% sure what you are asking but it seems that you just need to know how to find the length of a String. Not matter where the String variable is, you can use its length() method to find out how long it is.
Just like the example in your first post, it would be something like: