I want to contact two string.
Here my code
public class StringTest {
public String concat = "";
public String txt = "Hello "+concat;
protected void print() {
System.out.println("Output: " + txt);
}
public static void main(String[] args) {
StringTest tb = new StringTest();
tb.concat = "World";
tb.print();
}
}
Output: Hello
But I need "Hello World". It's possible ?
Conditions: Should't re-assign variable (get/set , inside method)