import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) {
String input = "original input";
Set<String> test = new HashSet<>();
test.add(input);
input = "modified input";
test.stream().forEach(name -> System.out.println(name));
System.out.println(input);
}
}
Output:
original input
modified input
Is there any structure in Java that I can pass this string object to, as a reference and both outputs would be the same modified input
when reading the string object from through the structure and reading the object directly?