java技術(shù)博客
jsp博客
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
數(shù)據(jù)加載中……
StudentTest1.java
/** */
/**
* main方法單獨(dú)設(shè)計(jì),編譯是不能通過
*/
public
class
StudentTest1
{
public
static
void
main(String[] args)
{
String[] course
=
{
"
計(jì)算機(jī)原理
"
,
"
編譯方法
"
,
"
數(shù)據(jù)結(jié)構(gòu)
"
}
;
Student one
=
new
Student(
"
Tom
"
,
"
20021024
"
);
one.setStudentCourse(course);
}
}
/** */
/**
* 我們設(shè)計(jì)的學(xué)生基本類
*/
class
Student
{
private
String strName
=
""
;
//
學(xué)生姓名
private
String strNumber
=
""
;
//
學(xué)號
private
String strSex
=
""
;
//
性別
private
String strBirthday
=
""
;
//
出生年月
private
String strSpeciality
=
""
;
//
專業(yè)
private
String strAddress
=
""
;
//
地址
public
Student(String name, String number)
{
strName
=
name;
strNumber
=
number;
}
public
String getStudentName()
{
return
strName;
}
public
String getStudentNumber()
{
return
strNumber;
}
public
void
setStudentSex(String sex)
{
strSex
=
sex;
}
public
String getStudentSex()
{
return
strSex;
}
public
String getStudentBirthday()
{
return
strBirthday;
}
public
void
setStudentBirthday(String birthday)
{
strBirthday
=
birthday;
}
public
String getStudentSpeciality()
{
return
strSpeciality;
}
public
void
setStudentSpeciality(String speciality)
{
strSpeciality
=
speciality;
}
public
String getStudentAddress()
{
return
strAddress;
}
public
void
setStudentAddress(String address)
{
strAddress
=
address;
}
public
String toString()
{
String information
=
"
學(xué)生姓名=
"
+
strName
+
"
, 學(xué)號=
"
+
strNumber;
if
(
!
strSex.equals(
""
) )
information
+=
"
, 性別=
"
+
strSex;
if
(
!
strBirthday.equals(
""
))
information
+=
"
, 出生年月=
"
+
strBirthday;
if
(
!
strSpeciality.equals(
""
) )
information
+=
"
, 專業(yè)=
"
+
strSpeciality;
if
(
!
strAddress.equals(
""
) )
information
+=
"
, 籍貫=
"
+
strAddress;
return
information;
}
public
void
setStudentCourse(
final
String[] strCourse)
{
class
Course
{
private
int
courseNumber
=
strCourse.length;
private
void
getCourse()
{
for
(
int
i
=
0
;i
<
courseNumber;i
++
)
{System.out.println(
"
\t
"
+
strCourse[i]);
}
}
public
void
getDescription()
{
System.out.println(
"
學(xué)生:
"
+
strName
+
"
student number is :
"
+
strNumber
+
"
。一共選了
"
+
courseNumber
+
"
門課,分別是:
"
);
getCourse();
}
}
Course course
=
new
Course();
course.getDescription();
}
}
posted on 2008-10-23 10:18
郭興華
閱讀(230)
評論(1)
編輯
收藏
評論
#
re: StudentTest1.java
2008-10-23 11:12
楊愛友
看不懂你的意思,代碼沒有縮進(jìn),看著很不習(xí)慣那。
回復(fù)
更多評論
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
Powered by:
BlogJava
Copyright © 郭興華
<
2008年10月
>
日
一
二
三
四
五
六
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
統(tǒng)計(jì)
隨筆 - 84
文章 - 1
評論 - 2
引用 - 0
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(3)
給我留言
查看公開留言
查看私人留言
隨筆分類
java每日練習(xí)代碼
(rss)
TESTARRAY(6)
(rss)
事件模型與事件處理
(rss)
隨筆檔案
2009年1月 (2)
2008年11月 (14)
2008年10月 (68)
文章檔案
2008年10月 (1)
搜索
最新評論
1.?re: jsp讀取*.TXT
請問 retstr是什么數(shù)據(jù)類型?String?好像不行哦
--jsp
2.?re: StudentTest1.java
看不懂你的意思,代碼沒有縮進(jìn),看著很不習(xí)慣那。
--楊愛友
閱讀排行榜
1.?java中的treemap(4603)
2.?JDBC連接SQLSERVER(1822)
3.?判斷一個一個路徑是否是目錄(1085)
4.?jsp讀取*.TXT(764)
5.?java代理模式(727)
評論排行榜
1.?StudentTest1.java(1)
2.?jsp讀取*.TXT(1)
3.?java1.5注解(二)(0)
4.?java1.5注解(一)(0)
5.?jsp中使用類(0)
主站蜘蛛池模板:
开封县
|
谢通门县
|
洱源县
|
宣威市
|
兴义市
|
武宁县
|
岗巴县
|
吴江市
|
濮阳县
|
镇赉县
|
南陵县
|
昭通市
|
商洛市
|
皮山县
|
台东市
|
乌恰县
|
永顺县
|
峨眉山市
|
巴林右旗
|
原平市
|
河北区
|
定日县
|
望城县
|
仪征市
|
工布江达县
|
绍兴县
|
兰州市
|
湖口县
|
阿合奇县
|
盐边县
|
黄骅市
|
云浮市
|
榆社县
|
万安县
|
汶川县
|
通州区
|
土默特右旗
|
广南县
|
清水县
|
西乌珠穆沁旗
|
古田县
|