Java经典面试题!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1.
请问“public void sit(){};”这种句型后面那个分号可以写成“public void sit(){;}”这样吗?或者写成“public void sit(){}”这样可以吗?
2.
在C语言里,大括号里面什么都没有就是空语句,比如可以这样写:
while(1)
{}
那在java里,是写成
while(true)
{}
还是写成
while(true)
{};
或者
while(true)
{;}
呢?
3.
为什么大括号里面都已经是空语句了,还要有一个分号呢?
比如“public void sit(){};”这个分号做什么用的?
interface HealthCare
{
void massage();
}
class Chair implements Sittable
{
public void sit(){};
}