本帖最后由 狐灵 于 2013-8-3 21:05 编辑
源码如下- class Student {
- String name;
- Double math;
- Double cn;
- Double en;
-
- public Student(String name, Double math, Double cn, Double en) {
- this.name = name;
- this.math = math;
- this.cn = cn;
- this.en = en;
- }
- public void printInfo() {
- System.out.println("name : " + this.name + ", math : " + this.math
- + ", cn : " + this.cn + ", en : " + this.en);
- }
- }
- public class TestStudent {
- public static void main(String[] args) {
- // Student stu = new Student("Jim", 90.0f, 90.0f, 90.0f);
- // Student stu = new Student("Jim", 90, 90, 90);
- Student stu = new Student("Jim", 90.0, 90.0, 90.0);
- stu.printInfo();
- }
- }
复制代码 // Student stu = new Student("Jim", 90.0f, 90.0f, 90.0f);
这行报错
// Student stu = new Student("Jim", 90, 90, 90);
这行报错
正常编译输出
|