How to use variable in @SimpleFunction?

here is my code

@SimpleFunction(description = "Simple addition of two numbers")
    public char Check(char text) {
        return text;
    }

i want to know how can i save the return text in a variable.

please explain me in details because i am new in developing.

please help me ASAP

You cannot return char directly, convert it to string.

Use String.valueOf(text) & what problem you're facing?

1 Like

Now it look like

@SimpleFunction(description = "Simple addition of two numbers")
    public char Check(String text) {
        return text;
    }

Simple addition example

@SimpleFunction(description = "Simple addition of two number")
     public long (long num1, long num2) {
         long sum = num1 + num2;
                return sum;
     }
1 Like

And how can i save in a variable

@SimpleFunction(description = "Store & return value")
    public String save(String text) {
       String val = text;
          return val;
    }
1 Like

One More Question
where i can create variable.

i don't know where i create new variable and please show me the code also

1 Like

I the java file :grinning:. Please learn at least basic java first. :sweat_smile:

2 Likes

i know java basics i know how to create variables.
here is the code

 int length  = inputString.length();

But i Don't know where to create this variable while making extension a extension for AI2

1 Like

do you have any extension's java file where you create variable and you use in @simple function

please help me

1 Like

Friend, I have my school work & other work too... :sweat_smile: You can check in open source extensions..

1 Like

okay, thanks for your reply :smile:

1 Like

An App Inventor extension is just Java code with some additional decoration (i.e., annotations). If you need a variable within a function, define it inside the function. If you need to use it across multiple invocations of the same function, or across different functions, define it at the top level of the class and either initialize it there or in the constructor.

3 Likes