Declare a string, and then using it in a function ?

Trying to figure out this string thing.

Example

String testString = "1234";
int stringLength = testString.length();

void setup()
{
Serial.begin(9600);
Serial.println(testString);
Serial.println(stringLength);
}

Result is

0 0

But i exspected to see

1234 4

How and why ?

String testString = "1234";
int stringLength = testString.length();

void setup()
{
Serial.begin(9600);
Serial.println(testString);
Serial.println(stringLength);
}
void loop(){}

For me, it won't compile without the void loop() and with it added, gives 1234 4

Trying to figure out this string thing.

You are better of using char arrays (aka string literals, c strings) with Arduino and its limited memory.