Passing int literal to a method that accepts an integer in java

This may be the dumbest question ever asked in a stack overflow, but it bothers me a lot ...

 public class shorte
{
    public static void main(String []args)
    {
        short e = 56; // no need for explicit cast
        System.out.println(e);
        start(56);  // why does int literal here needs explicit cast ...
    }
    static void start(short e)
    {
        System.out.println(e);
    }
}

when creating a normal short variable from int literal, the function did not request any explicit cast, but why passing an int literal to a short variable (passing parameters) requires explicit casting ...... ??

and again

i now it is not recommended to ask two unrelated questions in one message, but this is too trivial to ask in another message ..

** scope of the "for" counter variable **

    public class forloop
{
    public static void main(String []args)
    {
        int a =12;
        for(int a =12;a<14;++a) // no showdowing of variable ,give compile-time error
        {
            System.out.println(a);
        }
    }
}

so I tried it with regular blocks

   a=12
{
a=13; even this doesn't compile 
}

Does this mean that the blocks do not have their own area ...

+4
3

A short int Java.

short e=50;

. - . int short .

, , . :

1- (, ++, Java ).

2- .

(:: 1- this 2-).

+3

2:

int a =12;
        for(int a =12;a<14;++a) // no showdowing of variable ,give compile-time error
        {
            System.out.println(a);
        }

, , , , .

, , , , , .

1:

int , . . .

+1

( ;-)):

a)

5.2
[...]
, ( §15.28 ) , , char , :
• , , , char , .

b)

6,4
[...]
, v   , v ;     , v ; - , v .
+1

All Articles