Reputation: 59
I don't is this possible but what I am trying to do is passing the String from the one function to another function without passing that as a parameter.
In this code, the String result is already being pass through doInBackground, and I tried to do through calling the function but as there is a need of passing arguments, but I am not trying to figure out the one passing the value.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_convert);
String first = "Hero";
nameFor(first);
}
private String nameFor(String s){
Log.i("name", s);
return s;
}
private void loadInto(String result) throws JSONException {
String check = nameFor(*****);
}
Through this code, I am trying to get is that String first in the loadInto function storing that value check. The String result already have a JSON object. Any help will be really appreciated, really stuck.
Upvotes: 0
Views: 129
Reputation: 64
Strings are immutable so both of these will work fine.
String a = "Hello Wrold!";
String copy_of_a = new String(a);
String a = "Hello World!";
String copy_of_a = a;
Upvotes: 1