本帖最后由 杨威 于 2012-4-21 09:29 编辑
- package pack;
- public class Student
- {
- private String name;
- private int age;
- private double mark;
- public Student(String name,int age,double mark)
- {
- this.name = name;
- this.age = age;
- this.mark = mark;
- }
- public String getName()
- {
- return name;
- }
- public void setName(String name)
- {
- this.name = name;
- }
- public int getAge()
- {
- return age;
- }
- public void setAge(int age)
- {
- this.age = age;
- }
- public double getMark()
- {
- return mark;
- }
- public void setMark(double mark)
- {
- this.mark = mark;
- }
- }
复制代码- //package pack1;
- import pack.*;
- public class BaseTest6
- {
- public static void main(String[] args)
- {
- Student s1 = new Student("唐二",20,87.5);
- Student s2 = new Student("张三",18,84);
- double d1 = s1.getMark();
- System.out.println("d1="+d1);
- }
- }
复制代码 今天在练习包的导入import时,遇到这么一号问题:
编译后提示:
将上面的导包语句(import pack.*;)中的*改为Student或去掉打包语句后都可以编译运行成功。
但在没有上面打包语句时,导包时用通配符*怎么不行啊?????
|
|