1、在源程序中只有一个public类,是为了让程序在执行时只从一个接口导入。如果能有多个public类,程序就无法识别该从哪里导入程序了。比如说:
import java.io.*;
class student
{
private int id;
private float score;
public student(int id,float score)
{
this.id=id;
this.score=score;
}
public int getid()
{
return this.id;
}
public float getscore()
{
return this.score;
}
}
public class stu
{
public static void main(String args[] )
{
student a = new student(1,99);`
zt_soft(Get busy living, Or get busy dying.) 3、编译单元里面可以没有public 类,虽然这种情况不常见,但却是可以的。这时,你就能随意为文件起名字了。
zt_soft(Get busy living, Or get busy dying.) 能不能试举一例呢?让我们这些初学者见识见识(例子请尽量简单些)