zoukankan      html  css  js  c++  java
  • 2020.7.18第十三天

    1.学习了static关键字

    静态变量,静态方法以及静态模块

    1 public class VarDemo {
    2 private static int x=1;
    3 public static void main(String[] args){
    4 VarDemo.x++;
    5 VarDemo v=new VarDemo();
    6 v.x++;
    7 System.out.println("x="+x);
    8 }
    9 }
     1 public class StaticBlockDemo {
     2 static (
     3 System.out.println ("静态代码块") ;
     4 }
     5 public StaticBlockDemo() {
     6 System.out.println ("构造方法") ;
     7 }
     8 public static void main(String[] args) {
     9 StaticBlockDemo d=new StaticBlockDemo () ;
    10 StaticBlockDemo d2=new StaticBlockDemo () ;
    11 }
    12 }

    final关键字

    1 public class FinalVarDemo {
    2 private static final int x=5;
    3 public static void main(String[] args) {
    4 x=10;
    5 }
    6 }
    1 class A{
    2 public final void t() {
    3 System.out.println("A t()");
    4 class B extende A{
    5 public void t() (
    6 System.out.println("B t()") ;
    7 }
    8 }
    1 final class A{
    2 public final void t () (
    3 System. out.println("A t()");
    4 }
    5 }
    6 class B extends A{
    7 }

    final修饰的属性、方法和类均不能被重写

    abstract关键字

    抽象类

    abstract class 类名 {}
    public abstract class Type {
    }

    使用抽象方法必须使用抽象类的子类来实现

    必要时还要重写

     2.遇到的问题:小学期报告还在整理

    3.明天复习第五章

  • 相关阅读:
    ADO.Net对Oracle数据库的操作(转)
    代码反思(1)
    继承与多态
    存储过程
    linux学习流程及内容概括
    Linux下终端快捷键
    查找算法
    epoll解读
    TCP/udp编程
    如何学习嵌入式
  • 原文地址:https://www.cnblogs.com/Nojava/p/13337024.html
Copyright © 2011-2022 走看看