2016-06-12 2 views
-1

Ich bin mit Android Studio und ich möchte die FunktionenJava Short.ToUnsignedInt Nicht definiert

Byte.toUnsignedInt(...); 
Short.toUnsignedInt(...); 

verwenden, aber sie geben Compiler-Fehler, auch wenn ich sehe, dass diese Mitgliederfunktionen sind, die in der Kurz sein sollte und Byte-Klasse, aber es funktioniert nicht.

Hat jemand eine Idee?

D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:190: error: cannot find symbol 
       d_U = Short.toUnsignedInt(ind_U[i]) % 255; 
         ^
    symbol: method toUnsignedInt(short) 
    location: class Short 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:191: error: cannot find symbol 
       e_U = Short.toUnsignedInt(ind_U[i]) % 77; 
         ^
    symbol: method toUnsignedInt(short) 
    location: class Short 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:192: error: cannot find symbol 
       a_U = (byte)fSb2_U[(int)d_U]; 
          ^
    symbol: variable fSb2_U 
    location: class AESCrypt 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:193: error: cannot find symbol 
       b_U = (byte)rsB2_U[(int)e_U]; 
          ^
    symbol: variable rsB2_U 
    location: class AESCrypt 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:194: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(a_U) - Byte.toUnsignedInt(b_U)); 
           ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:194: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(a_U) - Byte.toUnsignedInt(b_U)); 
                 ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:194: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(a_U) - Byte.toUnsignedInt(b_U)); 
                        ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:194: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(a_U) - Byte.toUnsignedInt(b_U)); 
                              ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:195: error: cannot find symbol 
       low_U = (byte)(0x0F & Byte.toUnsignedInt(c_U)); 
             ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:196: error: cannot find symbol 
       high_U = (byte)((0xF0 & Byte.toUnsignedInt(b_U)) >> 4); 
              ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:199: error: cannot find symbol 
       d_U = Short.toUnsignedInt(ind_U[k]) % 255; 
         ^
    symbol: method toUnsignedInt(short) 
    location: class Short 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:200: error: cannot find symbol 
       e_U = Short.toUnsignedInt(ind_U[k]) % 89; 
         ^
    symbol: method toUnsignedInt(short) 
    location: class Short 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:201: error: cannot find symbol 
       a_U = (byte)rsB2_U[(int)e_U]; 
          ^
    symbol: variable rsB2_U 
    location: class AESCrypt 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:202: error: cannot find symbol 
       b_U = (byte)rsB2_U[(int)d_U]; 
          ^
    symbol: variable rsB2_U 
    location: class AESCrypt 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:203: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(c_U)); 
           ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:203: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(c_U)); 
                 ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:203: error: cannot find symbol 
       c_U = (byte)(Byte.toUnsignedInt(a_U)^Byte.toUnsignedInt(b_U)^Byte.toUnsignedInt(c_U)); 
                        ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:204: error: cannot find symbol 
       high_U = (byte)(0x0F & Byte.toUnsignedInt(c_U)); 
             ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
D:\MUD\ANDROID\ArduinoUSB\app\src\main\java\com\hariharan\arduinousb\AESCrypt.java:205: error: cannot find symbol 
       low_U = (byte)((0xF0 & Byte.toUnsignedInt(c_U)) >> 4); 
             ^
    symbol: method toUnsignedInt(byte) 
    location: class Byte 
19 errors 

FAILED 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':app:compileDebugJavaWithJavac'. 
> Compilation failed; see the compiler error output for details. 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

Antwort

0

See javadoc von Short.toUnsignedInt(short x):

seit: 1,8

Verfahren in Java 8 hinzugefügt wurde, Kompilieren so auf ältere Versionen von Java wird fehlschlagen.

Wenn Sie sich das Java 7 Dokument für Short ansehen, werden Sie sehen, dass die Methode nicht existiert.

+0

Ich habe Java 8, aber es funktioniert immer noch nicht. Dennoch, was für eine seltsame Welt wir leben, wo niemand in der Welt von Java 1,2,3,4,5,6,7 benötigt, um ein kurzes zu einem unsigned Int bis jetzt Java 8 zu konvertieren. Das hohe und mächtige Java " Götter, "die die Sprache entworfen haben, müssen außerhalb dieses Universums existieren, wo sie keine unsignierten Daten brauchen, nur wir Sterblichen und Ruff Raff brauchen solche kleinen Dinge. Wir sollten dankbar sein, dass sie daran erinnerten, Addition und Subtraktion darin zu setzen, bevor wir zu Java 10 kamen. – programmer3

+0

Seltsames Java kann all diese fantastischen Dinge tun, aber mit einem unsignierten Byte ist es zu viel für sie. – programmer3

+0

Es ist nicht so, als ob eine vorzeichenlose Erweiterung von short nach int schwierig ist: 'myInt = myShort & 0xFFFF;'. 'Short.toUnsignedInt()' ist nur eine nette Bequemlichkeitsmethode. – Andreas