cancel
Showing results for 
Search instead for 
Did you mean: 

Return??

Former Member
0 Kudos

Hello!

I have a problem: I have in my method()

String t = results[2];

String d = results[0];

with return t + d;

And I want to import it to other method1(). How can I do that??

Thanks!!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

It is not really clear what is your problem: compilation error, runtime error, other?

return (string1+string2) works perfectly for two strings. For example, the following code will be compiled with no issues:


String myMethod(String [] res) {
   if (res == null || res.length < 2) return null;
   return res[0] + res[1];
}

void myMethod2() {
  String [] res = new String [] {"Hello ", "Sue!"};
  String x = myMethod (res);
  System.out.println(x);
}

The fragment will print "Hello, Sue!"

Does it work for you?

Kind regards,

Tsvetomir

Answers (0)