| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 318 人关注过本帖
标题:java够着函数的定义问题!
只看楼主 加入收藏
陆嘉文
Rank: 1
来 自:江西
等 级:新手上路
帖 子:96
专家分:6
注 册:2011-11-10
结帖率:76.92%
收藏
 问题点数:0 回复次数:2 
java够着函数的定义问题!
程序代码:
package ch4;

import java.sql.Date;
class Person{
    int pid;
    Date birthday;
    String address;
    String name;
    boolean sex;
    Person(){
        pid=-1;
        name=null;
        sex=false;
        address=null;
    }
   
    Person(int pid,String name,boolean sex,Date birthday,String address){
        this.pid=pid;
        this.name=name;
        this.sex=sex;
        this.address=address;
    }
    public void setPoint(int x,boolean y){
    pid=x;
    sex=y;
        System.out.println(pid);
        if (sex) System.out.println("男");
        else
            System.out.println("女");
    }
}
class Student extends Person{
    int sno;
    String school;
    Student(){
        super();
        sno=-1;
        school=null;
    }
    Student(int pid,String name,boolean sex,Date birthday,String address,int sno,String school){
        super(pid,name,sex,birthday,address);
        this.sno=sno;
        this.school=school;
    }
    void printData(){
        System.out.println("姓名:"+name);
        System.out.println("学校:"+school);
        System.out.println("学号:"+sno);
    }
}
public class Ex4_7 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
  Person p=new Person();
  p.setPoint(100,true);
  Student t=new Student(11111,"陆嘉文",true,19900125,"金溪县",31,"电力职院");
  t.printData();
    }
}


这是JAVA的代码,请问我错在哪里啊!eclipse它是说我的Student够着函数没有定义,请问是怎么回事呢?
搜索更多相关主题的帖子: java address 
2012-05-21 13:01
Abiosis
Rank: 2
等 级:论坛游民
帖 子:13
专家分:33
注 册:2012-1-12
收藏
得分:0 
类型的问题  你输入的Student t=new Student(11111,"陆嘉文",true,19900125,"金溪县",31,"电力职院");里面 19900125这个不是Date类型
2012-05-21 16:40
Abiosis
Rank: 2
等 级:论坛游民
帖 子:13
专家分:33
注 册:2012-1-12
收藏
得分:0 
程序代码:
package org.testproject;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

class Person {
    int pid;
    Date birthday;
    String address;
    String name;
    boolean sex;

    Person() {
        pid = -1;
        name = null;
        sex = false;
        address = null;
    }

    Person(int pid, String name, boolean sex, Date birthday, String address) {
        this.pid = pid;
        this.name = name;
        this.sex = sex;
        this.address = address;
    }

    public void setPoint(int x, boolean y) {
        pid = x;
        sex = y;
        System.out.println(pid);
        if (sex)
            System.out.println("男");
        else
            System.out.println("女");
    }
}

class Student extends Person {
    int sno;
    String school;

    Student() {
        super();
        sno = -1;
        school = null;
    }

    Student(int pid, String name, boolean sex, Date birthday, String address,
            int sno, String school) {
        super(pid, name, sex, birthday, address);
        this.sno = sno;
        this.school = school;
    }

    void printData() {
        System.out.println("姓名:" + name);
        System.out.println("学校:" + school);
        System.out.println("学号:" + sno);
    }
}

public class Ex4_7 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Person p = new Person();
        p.setPoint(100, true);
       
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

        Date ss = null;
        try {
            ss = (Date) dateFormat.parse("1990-01-25");
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        Student t = new Student(11111, "陆嘉文", true, ss, "金溪县", 31, "电力职院");
        t.printData();
    }
}
给你改动了下   引用import java.util.Date;
2012-05-21 16:56
快速回复:java够着函数的定义问题!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018272 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved