Tag: 封装预览模式: 普通 | 列表
06-09
19

关于封装错误信息对象的问题(Struts版本问题)

ActionMessages errors = new ActionMessages();
errors.add("A", new ActionMessage("any.user",));
saveErrors(request, errors);
return (new ActionForward(mapping.getInput()));
}

查看更多...

Tags: Struts版本 封装 错误信息 ActionErrors

分类:Struts | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 638
06-06
02

封装以及构造方法的实例

class Person
{
 private int age;
 private String name;
 void shout()
 {
  if(age<0)
  return;
  System.out.println(name+"&aposs age is"+age);
 }
 public Person()
 {
 }
 public Person(String name)
 {
  this.name=name;
 }
 public Person(String name,int age)
 {
  this.name=name;
  this.age=age;
 }
 public void setAge(int age)
 {
  this.age=age;
 }
 public int getAge()
 {
  return age;
 }
 public void getSomeOne(Person p)
 {
  p.shout();
 }
 public static void main(String [] args)
 {
  Person p1=new Person("lisi");
  Person p2=new Person("zangsan",20);
  Person p3=new Person("wangwu");
  p1.age=-30;
  p1.shout();
  p2.shout();
  p3.shout();
 }
}

输出结果:

http://4sdu.blogbus.com/files/1149238415.jpg

Tags: 封装 构造方法

分类:学习 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 613