date cannot be resolved to a type是問題出在哪
小弟是初學者 剛寫了一個運用類別的程式
請問一下:跑出了
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
date cannot be resolved to a type
date cannot be resolved to a type
date cannot be resolved to a type
at datetest.main(datetest.java:5)
不知錯在哪
麻煩哪位大大知道的話可以說一下嗎?
我是用Eclipse寫的
以下是程式碼
====================================================================
public class datetest
{
public static void main(String args[])throws java.io.IOException
{
date day1;
date month1;
date year1;
java.io.BufferedReader keyin;
keyin=new java.io.BufferedReader(
new java.io.InputStreamReader(System.in));
System.out.print("input integer");
day1=Integer.parseInt(keyin.readLine());
month1=Integer.parseInt(keyin.readLine());
year1=Integer.parseInt(keyin.readLine());
System.out.print(day1.getday());
System.out.print(month1.getmonth());
System.out.print(year1.getyear());
}
}
============================================================
這是date類別
public class date
{
private int day,month,year;//date name for the class
public date(int i)//constructor to initialize the three variable
{
day=i;//initialize the day variable
}//ending the constructor
public void setday(int i)//method to set the day
{
day=i;//store the day name
}//end the set method
public int getday()//method to get the day
{
return day;//
}//end the get method
public void displaydate()//display the message of getday
{
System.out.print(getday());
}
public date(int j)
{
month=j;
}
public void setmonth(int j)
{
month=j;
}
public int getmonth()
{
return month;
}
public void displaydate()
{
System.out.print(getmonth());
}
public date(int k)
{
year=k;
}
public void setyear(int k)
{
year=k;
}
public int getyear()
{
return year;
}
public void displaydate()
{
System.out.print(getyear());
}
}
--
夫兵者不祥之器物或惡之故有道者不處君子居則貴左用兵則貴右兵者不祥之器非君子
之器不得已而用之恬淡為上勝而不美而美之者是樂殺人夫樂殺人者則不可得志於天下
矣吉事尚左凶事尚右偏將軍居左上將軍居右言以喪禮處之殺人之眾以哀悲泣之戰勝以
喪禮處之道常無名樸雖小天下莫能臣侯王若能守之萬物將自賓天地相合以降甘露民莫
之令而自均始制有名名亦既有夫亦將知止知止可以不殆 173-208.dorm.ncu.edu.tw海
討論串 (同標題文章)
java 近期熱門文章
PTT數位生活區 即時熱門文章
18
25