hello world 的各种输出方式(1)闲的蛋疼
来源:互联网 发布:淘宝美工职业生涯规划 编辑:程序博客网 时间:2024/06/03 14:47
class Person{ private String name; public String getName() { return name; } public void setName(String name) { this.name = name; }}class Member{ private Member(){ } private static Member instance=new Member(); public static Member getInstance(){ return instance; } public void print(){ System.out.println("hello word"); }}class Student{ private String num; private Student(String num){ this.num=num; } private static final int mem=10; private static final Student M1=new Student("hello word"); public static Student getM(int m){ switch(m){ case mem: return M1; default: return null; } } public String toString(){ return this.num; }}interface Iprint{ public void print();}class Final implements Iprint{ public void print(){ System.out.println("word"); }}class Poly implements Iprint{ private Final f; public Poly(Final f){ this.f=f; } public void first(){ System.out.println("hello"); } public void print(){ first(); this.f.print(); }}class Factory{ public static Iprint getInstance(){ return new Poly(new Final()); }}interface In{ public void print();}abstract class Father{ public abstract void println();}class Son extends Father{ public void println() { // TODO Auto-generated method stub System.out.println("hello word"); }}class Array{ private String h="helloword"; char[] data=h.toCharArray(); public void print(){ for(int x=0;x<data.length;x++){ System.out.print(data[x]+" "); } }}class Link{ private class Node{ private Node next; private Object data; public Node(Object data){ this.data=data; } public void addNode(Node node){ if(this.next==null){ this.next =node; }else{ this.next.addNode(node); } } public void toArrayNode() { Link.this.reData[Link.this.foot++]=this.data; if(this.next!=null){ this.next.toArrayNode(); } } } private int count; private Node root; private int foot; private Object[]reData; public void add(Object data){ if(data==null){ return; } Node node =new Node(data); if(this.root==null){ this.root=node; }else{ this.root.addNode(node); }count++; } public Object[]toArray(){ if(this.count==0){ return null; } this.reData=new Object[this.count]; this.foot=0; this.root.toArrayNode(); return this.reData; }}public class Hello { public static void main(String[] args) { System.out.println("Hello word"); Member mem=Member.getInstance(); mem.print(); System.out.println(Student.getM(10)); Iprint i=Factory.getInstance(); i.print(); new In(){ public void print(){ System.out.println("hello word"); } }.print(); Father f=new Son(); f.println(); new Array().print(); Person p=new Person(); p.setName("hello word"); System.out.println(); System.out.println(p.getName()); Link l=new Link(); l.add("hello"); l.add("word"); Object[]data=l.toArray(); for(int x=0;x<data.length;x++){ System.out.print(data[x]+" "); } }}
Hello word
hello word
hello word
hello
word
hello word
hello word
h e l l o w o r d
hello word
hello word
阅读全文
0 0
- hello world 的各种输出方式(1)闲的蛋疼
- 各种小巧的Hello World
- Hello World的各种写法
- 各种语言的hello world!
- 各种语言的Hello,World程序大集合(一)
- 各种语言的Hello,World程序大集合(二)
- 各种语言的Hello,World程序大集合(三)
- 各种语言的Hello,World程序大集合(四)
- 各种语言的Hello,World程序大集合(五)
- 各种语言的Hello,World程序大集合(六)
- 各种编程语言的Hello world程序
- 各种语言的 Hello world 程序
- 各种语言的Hello World程序
- 各种编程语言的Hello World程序
- 各种语言的Hello World程序
- 各种编程语言的 Hello World
- 在控制台输出彩色的Hello World!
- 为什么输出是Hello?而不是Hello World?的内存分析
- 二代身份证编码规则及校验代码实现
- POJ
- winsock编程框架
- 暑假第16天总结
- 组合数C(m,n)——模板
- hello world 的各种输出方式(1)闲的蛋疼
- leetcode(136). Single Number
- 【jzoj5290】【NOIP2017提高组A组模拟8.17】【行程的交集】
- call_user_func()
- MapReduce中input split和block的划分以及maptask和reducetask数量的确定
- 复制文件跟FileReader\FileWriter 和FileInputStream\FileOutputStream的区别
- QT+Opencv实现人脸检测与性别识别(1)
- 流水线控制
- apache httpcomponents-client4.5.3 学习笔记