zoukankan      html  css  js  c++  java
  • java入门学习

    继承性 覆写 多态性

    //class A{
    //	public void fum() {
    //		System.out.println("A中的方法");
    //	}	
    //}
    //class B extends A{
    //	public void fum() {
    //		System.out.println("B中的方法");
    //	}
    //	public void fumB(){
    //		System.out.println("奥利给");
    //	}
    //}
    //
    //public class Demo4{
    //	public static void main(String args[]) {
    //		B b=new B();
    //		tt(b);
    //	}
    //	public static void tt(A a) {
    //		a.fum();
    //		if(a instanceof B) {
    //			B b=(B) a;
    //			b.fumB();
    //		}
    //	}
    //}
    
    
    //class Array{
    //	private int data[];
    //	private int len;
    //	private int x=0;
    //	public Array(int len) {
    //		if(len>0)
    //			this.len=len;
    //		else
    //			this.len=1;
    //		this.data=new int[this.len];
    //	}
    //	public void addArray(int t) {
    //		System.out.println(this.x<len);
    //		if(this.x<len) {
    //			this.data[x++]=t;	
    //		}
    //	}
    //	public int getLen() {
    //		return this.len;
    //	}
    //	public int[] getInfo() {
    //		return this.data;
    //	}
    //}
    //class A extends Array{
    //	public A(int len){
    //		super(len);
    //	}
    //	public void getSort() {
    //		java.util.Arrays.sort(this.getInfo());
    //		for(int i=0;i<this.getLen();i++) {
    //			System.out.println(this.getInfo()[i]);
    //		}
    //	}
    //}
    //class B extends Array{
    //	public B(int len){
    //		super(len);
    //	}
    //	public int[] getData() {
    //		int head=0;
    //		int tail=this.getLen()-1;
    //		while(head<=tail) {
    //			int t=getInfo()[head];
    //			getInfo()[head]=getInfo()[tail];
    //			getInfo()[tail]=t;
    //			tail--;
    //			head++;	
    //		}
    //		return this.getInfo();
    //	}
    //}
    //public class Demo4{
    //	public static void main(String args[]) {
    //		B a =new B(5);
    //		a.addArray(1);
    //		a.addArray(2);
    //		a.addArray(3);
    //		a.addArray(10);
    //		a.addArray(5);
    //		a.addArray(-789);
    //		a.getData();
    //		for(int i=0;i<a.getLen();i++) {
    //			System.out.println(a.getInfo()[i]);
    //		}
    //	}
    //}
    
    
    //验证方法的覆写
    //class A{
    //	private String name;
    //	public void fum() {
    //		System.out.println("A中的方法");
    //	}
    //}
    //class B extends A{
    //	
    //	public void fum() {
    //	System.out.println("B中的方法");
    //	}
    //}
    //class C extends A{
    //	public void fum() {
    //		System.out.println("C中的方法");
    //	}
    //}
    //public class Demo4{
    //	public static void main(String args[]) {
    //		new B().fum();
    //		new C().fum();
    //	}
    //}
    
    
    
    //验证了B类继承A类
    //class A{
    //	private String name;
    //	private double price;
    //	public A(String name,double price){
    //		System.out.println("A 类构造方法");
    //		this.name=name;
    //		this.price=price;
    //	}
    //	public String getName() {
    //		return this.name;
    //	}
    //	public double getPrice() {
    //		return this.price;
    //	}
    //}
    //class B extends A{
    //	private String school;
    //	public B(String name,double price,String school) {
    //		super(name,price);
    //		System.out.println("B 类构造方法");
    //		this.school=school;
    //	}
    //	public String getInfo() {
    //		return "姓名:"+this.getName()+"
    价格:"+this.getPrice()+"
    学校:"+this.school;
    //	}
    //}
    //public class Demo4{
    //	public static void main(String args[]) {
    //		B b=new B("老狗",250,"清华");
    //		System.out.println(b.getInfo());
    //	}
    //}
    
  • 相关阅读:
    xpage 获取 附件
    Win8.1应用开发之离线缓存
    分布式系统设计系列 -- 基本原理及高可用策略
    hdu3652(数位dp)
    HDU 4869 Turn the pokers
    ubuntu 安装mysql, 以及全然又一次安装的方法
    Wildcard matching
    并发编程:创建进程 join方法 进程间的数据隔离问题 进程对象以及其他方法 守护进程 互斥锁
    网络通信 : 粘包解决的实例 socketserver模块 udp的使用 简易版QQ的实现 异常处理机制的知识点
    TCP通信: scoket模块 黏包问题 连接循环 通信循环
  • 原文地址:https://www.cnblogs.com/fxzemmm/p/14847961.html
Copyright © 2011-2022 走看看