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);
        }
    }
  • 相关阅读:
    ASP.NET中Session,Application,Viewstate,Cache,隐藏域和带参数的传接收值的用法
    JS页面跳转搜集
    SQL中常用的日期转化
    DIV+CSS兼容性解决IE6/IE7/FF浏览器的通用方法
    C#中将数据导出为EXCEL方式汇总
    正则表达式大全
    ASP.NET中Cookie用法小节
    div+CSS浏览器兼容问题整理
    站长常用的200个js代码
    [转]主机和终端
  • 原文地址:https://www.cnblogs.com/xkxf/p/6431142.html
Copyright © 2011-2022 走看看