您的位置:首页 > 编程语言 > Java开发

java第一个类的测试小例子

2015-07-09 08:31 375 查看
主类:

package testClassPropertys;

import java.util.ArrayList;
import java.util.List;

public class testClass {

static void w(String msg) {
System.out.println(msg);
}

public static void main(String[] args) {
// TODO Auto-generated method stub
Plait p = new Plait("xx01", "updateInfo01", "updateDateTime01");
initListData();
w(p.title);
w(p.updateInfo);
w(p.updateDateTime);

w(p.getTitle());
w(p.getUpdateInfo());
w(p.getUpdateDateTime());
w("" + list.size());
p = list.get(1);
w(p.title);
w(p.getTitle());
w(p.getUpdateDateTime());
}

static List<Plait> list;

static void initListData() {
list = new ArrayList<Plait>();
Plait p = new Plait("織片20150701001", "已同步", "2015.01.01");
list.add(p);
Plait p1 = new Plait("織片20150701002", "已同步", "2015.01.02");
list.add(p1);
Plait p2 = new Plait("織片20150701003", "新", "2015.01.03");
list.add(p2);
}
}


另外一个类:

package testClassPropertys;

public class Plait {
public String title;
public String updateInfo;
public String updateDateTime;

// Constructor.
public Plait(String title, String updateInfo, String updateDateTime) {

this.title = title;
this.updateInfo = updateInfo;
this.updateDateTime = updateDateTime;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getUpdateInfo() {
return updateInfo;
}

public void setUpdateInfo(String updateInfo) {
this.updateInfo = updateInfo;
}

public String getUpdateDateTime() {
return updateDateTime;
}

public void setUpdateDateTime(String updateDateTime) {
this.updateDateTime = updateDateTime;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java