There is no add() method in String class. One can perform String concatenation in Java using + operator.
String s = "abc:def:ghi";
s = s + s.split(":")[0]; // or s += s.split(":")[0]
System.out.println(s);
The above snippet will print abc:def:ghiabc
Add null checks and index bounds checks as per your requirements.
Please check alternative ways at String Concatenation | StackOverflow
EDIT (As per OP's comment on question)
If you're looking to make changes to the input String object 'raw' and expect it to reflect in caller method, then it's not possible as String is immutable in Java. Correct way to achieve that would be to return the result from your method and assign that to String in caller method.
public void myMethod() {
String s = "abc:def:ghi";
s = process(s);
System.out.println(s);
}
public String process(String raw) {
if (raw != null) {
String[] str_array = raw.split(":");
String humid1 = str_array[0];
if (humid1 != null) {
return humid1;
}
}
return null; \\ or throw exception as per your choice.
}
The above snippet should print abc
. More details String Immutability in Java | StackOverflow.