简体   繁体   中英

Casting a primitive to a custom class

I am trying to do something concerning the primitive char. By itself, one could use

((int)char)

to get the integer value of that character. However, due to the way this is formatted, I cannot do this. Is there a way to allow casting of a certain class, such as CustomInt, and determine which characters turn into what number?

Example:

((int)'A') == 68;
((CustomInt)'A') == 0;

Thanks for the help.

Not possible. Write a method public static CustomInt valueOf(char x) instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM