Search code examples
javastorejavacard

Store a String data into my JavaCard


I need to know how to store String data in my JavaCard, any help please ? P.S : JavaCard does not support String type.


Solution

  • Java Card Three small primitive data types only (boolean, byte, short)
    It has Optional support for integer (int) primitive data type.

    Strings can be represented as array of characters or bytes.
    However characters are not supported(As for as I know).

    Hence you can represent it using array of bytes:

    byte str[]; //creating array of byte
    str = {'s' , 't' , 'a' , 'c' , 'k'}; // initializing array
    

    My answer is same as above but with little more explanation.
    Hope this helps.