how to declare string code example Example 1: declare String in java String stringName = "your string content"; Example 2: declare string in c char string[20];