zoukankan      html  css  js  c++  java
  • 代码块练习题:看代码写程序的执行结果。

     1 /*
     2     代码块练习题:
     3         看代码写程序的执行结果。
     4     
     5     输出结果是:
     6         林青霞都60了,我很伤心
     7         我是main方法
     8         Student 静态代码块
     9         Student 构造代码块
    10         Student 构造方法
    11         Student 构造代码块
    12         Student 构造方法
    13 */
    14 
    15 class Student {
    16     static {
    17         System.out.println("Student 静态代码块");
    18     }
    19     
    20     {
    21         System.out.println("Student 构造代码块");
    22     }
    23     
    24     public Student() {
    25         System.out.println("Student 构造方法");
    26     }
    27 }
    28 
    29 class StudentDemo {
    30     static {
    31         System.out.println("林青霞都60了,我很伤心");
    32     }
    33     
    34     public static void main(String[] args) {
    35         System.out.println("我是main方法");
    36         
    37         Student s1 = new Student();
    38         Student s2 = new Student();
    39     }
    40 }

  • 相关阅读:
    PHP 单态设计模式
    五中常见的PHP设计模式
    PHP如何定义类及其成员属性与操作
    thinkphp 中MVC思想
    1.4 算法
    1.3 迭代器
    1.2 容器-container
    1.1 STL 概述
    2.3顺序容器-deque
    2.2 顺序容器-list
  • 原文地址:https://www.cnblogs.com/chenmingjun/p/8448996.html
Copyright © 2011-2022 走看看