Type of constant expressions in Java -


this question has answer here:

why bar int i signature called?

public class test {   public static void main(string[] args) {     bar(5);  // type of integer "5"?   }    public static void bar(short i) {      system.out.println("short");   }    public static void bar(int i) {      system.out.println("int");       }    public static void bar(long i) {      system.out.println("long");   } } 

i've checked oracle's documents 15.12. method invocation expressions , 15.28. constant expressions, while still have no idea.

could explain type of constants expression? type of "5" above?

thanks!

in java, when write plain literal integer, assumed of type int, unless specify otherwise casting type, or adding postfix l long, f float. example:

long    →   1234l float   →   25f short   →   (short)5 double  →   (double)25 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -