zoukankan      html  css  js  c++  java
  • java第五天

    p37:

    练习1

    /**
     * Created by xkfx on 2017/2/22.
     */
    public class DataOnly {
        int anInt;
        char aChar;
        public static void main(String[] args) {
            DataOnly dateOnly = new DataOnly(); // 静态方法中无法直接打印成员数据,需要先new一个对象
            System.out.println(dateOnly.anInt + " " + dateOnly.aChar);
        }
    }

    练习2

    /**
     * Created by xkfx on 2017/2/22.
     */
    public class HelloWorld {
        public static void main(String[] args) {
            System.out.println("Hello, World"); // System类位于默认导入的java.lang包中,out是该类的静态成员,可以通过类名直接使用。
        }
    }

    练习3

    /**
     * Created by xkfx on 2017/2/22.
     */
    public class ATypeName {
        public static void main(String[] args) {
            ATypeName a = new ATypeName();  // 这个内容在书的第25页
        }
    }

    练习4、练习5

    class DataOnly {
        int i;
        double d;
        boolean b;
        DataOnly() {
            this.i = 47;
            this.d = 1.1;
            this.b = false;
        }
        public static void main(String[] args) {
            DataOnly dataOnly = new DataOnly();
            System.out.println(dataOnly.i + " " + dataOnly.d + " " + dataOnly.b);
        }
    }

    练习6

    /**
     * Created by xkfx on 2017/2/22.
     */
    public class TestStorage {
        static int storage(String s) {
            return s.length() * 2;
        }
        public static void main(String[] args) {
            int length = TestStorage.storage("Not a hello world.");
            System.out.println(length);
        }
    }

    练习7

    /**
     * Created by xkfx on 2017/2/22.
     */
    class Incrementable {
        static void increment() { StaticTest.i++; }
    }
    class StaticTest {
        static int i = 47;
        public static void main(String[] args) {
            Incrementable.increment();
            System.out.println(i);
        }
    }
  • 相关阅读:
    一元回归1_基础(python代码实现)
    fisher's exact test
    卡方检验(python代码实现)
    Hough transform(霍夫变换)
    【算法】怎样把一个单链表反序?
    HTTP请求格式和HTTP响应格式
    TCP/IP、SOCKET、HTTP之间的联系与区别
    Graphical vi-vim Cheat Sheet and Tutorial
    Linux远程上传、下载文件的方法
    matlab工作空间,变量的保存和载入
  • 原文地址:https://www.cnblogs.com/xkxf/p/6431142.html
Copyright © 2011-2022 走看看