Why I got The local variable arcType may not have been initialized error?
1st Case :
String arcType;
if (//somecondition) {
arcType += "Test"; // Here it show the error
System.out.println(arcType);
}
But below working fine.
2nd Case :
String arcType = null;
if (//somecondition) {
arcType += "Test"; // It's working fine
System.out.println(arcType);
}
Output of the above program : nullTest
If I initialize my String with space then space concatenate with Test. Using trim space will remove but I don't want to use trim.
My question are :
Why I got
The local variable arcType may not have been initializederror in first case?In 2nd case when I initialize my string with
nullthen why I got outputnullTest?
I want output only Test.