文章标题
来源:互联网 发布:淘宝店铺全套免费模板 编辑:程序博客网 时间:2024/06/07 03:12
1.有一个抽象类 如下: 要求把代码补全
public abstract class AutoInvoke {
public void putValue(String name,Object value){ //补充代码} public Object outValue(String name){ //补充代码 return null; }
}
2.一个子类继承上面抽象类:
public class Student extends AutoInvoke{
private String name; private Integer age; private java.util.Date birthday; private String address; private String email; private String phone;get/setpublic String toStirng(){return "name=......"}
}
3.测试类中:
public class Test{
main:Student o = new Student (); o.putValue("Name", "tom"); o.putValue("Email", "abc@163.com"); o.putValue("Phone", "19999999"); o.putValue("Address", "地址"); o.putValue("Age", 24); o.putValue("Birthday", new Date()); System.out.println(o); System.out.println("----------------");System.out.println(o.outValue("name"));System.out.println(o.outValue("email"));System.out.println(o.outValue("phone"));
}
————————————————分割线——————————————————
package com.briup.test;
import java.lang.reflect.Method;
import java.util.Date;
public class Student extends AutoInvoke{
private String name;
private Integer age;
private Date birthday;
private String address;
private String email;
private String phone;
public static void main(String[] args) { Student o = new Student (); o.putValue("Name", "tom"); o.putValue("Email", "abc@163.com"); o.putValue("Phone", "19999999"); o.putValue("Address", "地址"); o.putValue("Age", 24); o.putValue("Birthday", new Date()); System.out.println(o); System.out.println("----------------"); System.out.println(o.outValue("Name")); System.out.println(o.outValue("Email")); System.out.println(o.outValue("Phone")); System.out.println(o.outValue("Address")); System.out.println(o.outValue("Age")); System.out.println(o.outValue("Birthday"));}@Overridepublic String toString() { return "Student [name=" + name + ", age=" + age + ", birthday=" + birthday + ", address=" + address + ", email=" + email + ", phone=" + phone + "]";}public String getName() { return name;}public void setName(String name) { this.name = name;}public Integer getAge() { return age;}public void setAge(Integer age) { this.age = age;}public Date getBirthday() { return birthday;}public void setBirthday(Date birthday) { this.birthday = birthday;}public String getAddress() { return address;}public void setAddress(String address) { this.address = address;}public String getEmail() { return email;}public void setEmail(String email) { this.email = email;}public String getPhone() { return phone;}public void setPhone(String phone) { this.phone = phone;}
}
abstract class AutoInvoke {
private Class
阅读全文
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 数据结构实验之链表七:单链表中重复元素的删除
- 79. Word Search
- Servlet 监听器----ServletRequest
- 五大常用算法之三:贪心算法
- 一些实用网站
- 文章标题
- java 最长公共子序列(LSC)问题
- [译]图像分类:数据驱动方法、K-最近邻、train/val/test分离 (2)
- Educational Codeforces Round 26 E. Vasya's Function 数学,迭代法
- 如何修改Tomcat服务器Server Locations
- Android Studio 2.2 更方便地创建JNI项目-CMake
- howto prevent a process from terminating when writing to a broken pipe
- poj 2796 单调栈
- hdu 4609 3-idiots(FFT)