学习Java06
来源:互联网 发布:中美合作 规范网络 编辑:程序博客网 时间:2024/05/01 17:23
简单的单向链表:
class Node{private String data;private Node next;public Node(String data){this.data=data;}public String getData(){return this.data;}public void setNext(Node next){this.next=next;}public Node getNext(){return this.next;}public void addNode(Node newNode){if(this.next==null){this.next =newNode;}else{this.next.addNode(newNode);}}public void printNode(){System.out.println(this.data);if(this.next !=null){this.next.printNode();}}}class Link{private Node root;public void add(String data){if(data==null){return;}Node newNode= new Node(data);if(this.root==null){this.root=newNode;}else{this.root.addNode(newNode);}}public void print(){if(this.root!= null){this.root.printNode();}}}public class Day { public static void main(String args[]) { Link all =new Link();all.add("1");all.add("2");all.add("3"); all.add("4");all.add("5");all.print();} }验证通过.
继承的一个简单模型":
class Person{private String name;private int age;public void setName(String name){this.name=name;}public String getName(){return this.name;}public void setAge(int age){this.age=age;}public int getAge(){return this.age;}}class Student extends Person{private String school;public void setSchool(String school){this.school=school;}public String getSchool(){return this.school;}}public class Day { public static void main(String args[]) { Student stu=new Student(); stu.setName("heyao"); stu.setAge(22); stu.setSchool("Central South University"); System.out.println(stu.getName()+">>>>>"+stu.getAge()+">>>>>>"+stu.getSchool());} }
0 0
- 学习Java06
- Java06集合
- Java06 Low-coupling And Height-coheison
- 高效Java06:消除过期的对象引用
- 重拾Java回忆录(六):java06常用的类型分类
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 学习
- 游戏服务器之角色移动
- ZooKeeper是什么
- 博客啊博客
- Leetcode Jump Game 解题报告
- 写给自己
- 学习Java06
- JSP确定文件路径方法
- splay bzoj1251序列终结者
- mahout学习进度
- Pro Android学习笔记(七五):HTTP服务(9):DownloadManager
- Extjs之自动消失提示框(Ext.example.msg)
- 通过__index实现创建子类对象
- Mistserver 介绍 - 一个轻量级高可扩展性的媒体服务器
- UVa:11732 strcmp() Anyone?