zoukankan      html  css  js  c++  java
  • Java 基础知识

    1. 接口只能用public 来修饰

    2 http:超文本传输协议    端口 80 

      smtp:简单邮件传输协议 端口25

      ftp 21 ssh 22 

    3 public int aMethod(){
    static int i=0;
    i++;
    }

    编译出错,不能在类中声明静态变量

    4 class Super {
    public Integer getLenght() { return new Integer(4); }
    }

    public class Sub extends Super {
    public Long getLenght() { return new Long(5); }
    public static void main(String[] args) {
    Super sooper = new Super();
    Sub sub = new Sub();
    System.out.println(sooper.getLenght().toString() + "," +
     sub.getLenght().toString() );
    }
    }

    编译失败.---------重定时不能改变返回类型

    5

    class Parent{
        String name="parent_name";
        static {
            System.out.println("parent_static");
        }
        public Parent() {
            // TODO Auto-generated constructor stub
            System.out.println("parent_constructor");
        }
        public void method(){
            System.out.println("parent");
        }
        public static void smethod(){
            System.out.println("parent_1");
        }
    }
    class Child extends Parent{
        String name="child_name";
        static {
            System.out.println("child_static");
        }
        public Child() {
            // TODO Auto-generated constructor stub
            System.out.println("child_constructor");
        }
        public void method(){
            System.out.println("child");
        }
        public static void smethod(){
            System.out.println("child_1");
        }
    }
    public class Test5 {
    
        
        public static void main(String[] args) {
            Child c=new Child();
            System.out.println("---------------");
            Parent p=new Parent();
            System.out.println("------------------");
            p.method();
            System.out.println("--------------");
            c.method();
            System.out.println("--------------");
            Parent ddd=new Child();
            System.out.println("--------------");
            System.out.println(ddd.name);
            ddd.method();
        }
    }
  • 相关阅读:
    【转】数据库中查询记录时是否每次只能使用一个索引?
    【转】MySQL理解索引、添加索引的原则
    【转】.htaccess详解及.htaccess参数说明
    【转】BASE64编码简介
    【转】联想笔记本进入u盘启动项操作方法详解
    【转】UEFI是什么?与BIOS的区别在哪里?UEFI详解!
    55. Jump Game
    54. Spiral Matrix
    53. Maximum Subarray
    52. N-Queens II
  • 原文地址:https://www.cnblogs.com/csxf/p/3985560.html
Copyright © 2011-2022 走看看