Search code examples
androidintegerintconvertersshort

Short to Int conversion


I am looking for a way to convert a Short to an Int. I tried to cast it with

short i = 5;
int t = (int) i;

But this doesn't work. Also in the Short function itself I cannot see something like an toInt() function...


Solution

  • The follow code can be a (not elegant) solution of your problem:

    short i = 5;
    int t = 0;
    t = t+i;