سؤال

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...

هل كانت مفيدة؟

المحلول

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

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

نصائح أخرى

Did you look at "Short" the wrapper class?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top