for example, i have this class:
public class Col {
static void test(int a)
{
System.out.println("int");
}
public static void main(String args[])
{
Col.test(12); //1
Col.test((byte)12); //2
Col.test((long)100); //3
}
}
and now me intresting how algoritm work this code. I think, that this steps:
1 line - all correct call method with int param, perfect.
2 line - call method with byte param...oooops. what do? Java try widening byte to int? Its true?
3 line call method with long param... again ooops. what do? convert long to int java can't, because loss of accuracy. its try? And in result - Exception.
Than I add this:
public static void test(Object a)
{
System.out.println("Object");
}
and if a call:
Col.test((long)100);
all correct, no Exception so, what the relation between primitive type long and Object?