zoukankan      html  css  js  c++  java
  • Java于 初始化序列?

    我们正处于java于

    Java中初始化的顺寻?

    java代码:

    package sru.love.c;
    
    
    
    class Person
    {
    	String name = "Person";
    	
    	static
    	{
    		System.out.println("我是 Person 的  static 代码块");	
    	}
    	
    	{
    		System.out.println("我是 Person 构造代码块");
    	}
    	
    	Person()
    	{
    		System.out.println("我是person() 的无参构造函数。!");
    	}
    
    	Person(String name)
    	{
    		
    		this.name = name;
    	}
    	
    	void show()
    	{
    		System.out.println(" Person 的名字"+this.name);
    	}
    	
    }
    
    
    class Student extends Person
    {
    	int grade=2;
    	
    	static
    	{
    		System.out.println("我是 Student 的  static 代码块");	
    	}
    	
    	{
    		System.out.println("我是 Student 构造代码块");
    	}
    	
    	
    	
    	 Student()
    	 {
    		
    		 System.out.println("我的是Student 的无参构造函数! ");
    	 }
    	 
    	 Student(String name,int grade)
    	 {
    		 super(name);
    		 this.grade = grade;
    	 }
    	 
    	 void show()
    	 {
    		 
    		 System.out.println("我的几"+this.grade+"班的学生");
    	 }
    	 
    	
    }
    
    public class SuperDemo {
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    
    		Student s = new Student();
    		
    		s.show();
    		
    	}
    
    }
    

    执行结果:



    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    python面试
    Python 3.x--使用re模块,实现计算器运算实例
    Python 3.x--模块导入
    Python 3.x--序列化及反序列化
    Python 3.x--装饰器
    Python 3.x--函数的参数问题
    Python 3.x--文件seek、tell的用法
    Python 3.x--字典循环
    Python3.x--文件读写与list
    Python简介
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/4834331.html
Copyright © 2011-2022 走看看