按我的理解,0被视为int第1行,这就是为什么分配默认int到boolean是给编译时错误.这是对的吗?另外,为什么它会在第2行给出编译错误,即使是明确的向下转换?
public class HelloWorld
{
public static void main(String[] args)
{
boolean b = 0; //1.compile time error
boolean b = (boolean)0;//2.still compile time error
System.out.print(b);
}
}
Run Code Online (Sandbox Code Playgroud)