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