Extension Build Problem

Hello i am very new in extension development filed.

So can anyone tell me how i return two int like this a,b

Capture

2 Likes

Are you asking to return an array of both? Subtract them? Divide them? Multiply them? What are you asking.

1 Like

only i just return two numbers just with coma symbol(,)

120,250 like this

That’s invalid Java sentence. To return a list or YailList

java.util.List<Integer> numbers = Arrays.asList(1, 1);

return com.google.appinventor.components.runtime.util.YailList.makeList(numbers);

And which IDE are you using to write you’re code?

I am using Notepad+

You can do this…

Method One

// You might need to import java.lang.StringBuilder

@SimpleFunction
public String Test(int a, int b) {
  StringBuilder sb = new StringBuilder();
  sb.append(a);
  sb.append(",");
  sb.append(b);
  return sb.toString();
}

Method Two

// You might need to import java.lang.String, this should be done
// by default though

@SimpleFunction
public String Test(int a, int b) {
  return String.valueOf(a) + "," + String.valueOf(b);
}

Method Three

@SimpleFunction
public String Test(int a, int b) {
  return a + "," + b;
}
3 Likes

Notepad+ is not Java IDE.

This is really not needed when you can just return directly

return a + "," + b;
1 Like

Sorry, I didn’t include that because I thought Java might throw an error, but it seems as though I was thinking of a.toString() that would throw an error.

1 Like

So can you tell me which Java IDE Is best for create extensions??

Thanks Your Method Two Is Working.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.