zoukankan      html  css  js  c++  java
  • 20145124陈威名 《Java程序设计》第3周学习总结

    20145124陈威名 《Java程序设计》第3周学习总结

    教材学习内容总结

    我学会了区分基本类型与类类型。
    了解对象与参考的关系。
    打包器认识对象。
    以对象观点看待数组。
    认识字符串的特性。
    java.util.Arrays类能方便地操作数组,它提供的所有方法都是静态的。
    java.lang.System类提供了实用方法拷贝元素到另一个数组。
    构造函数的重载 final可修饰类、域(变量和常量)、方法 (而static不修饰类)。

    教材学习中的问题和解决过程

    1:定义类
    class Cloth {
    String color;
    char size;

    Cloth(String color, char size) {
        this.color = color;
        this.size = size;
    }
    

    }
    2:定义数组
    int[][] cords ={
    {1,2,3},
    {4,5,6}

             };
            for(int x=0;x<cords.length;x++){
                for(int y=0;y<cords[x].length;y++){
                    System.out.printf("%2d",cords[x][y]);
                }
                System.out.println();
    

    3:循序地走访二维数组
    for(int[] row:cords){
    for(int value:row){
    System.out.printf("%2d",value);
    }
    }

    4:不规则数组
    int[][] arr = new int[2][];
    arr[0] = new int[] {1,2,3,4,5};
    arr[1] =new int[] {1,2,3};
    for(int[] row : arr){
    for(int value : row){
    System.out.printf("%2d",value);
    }
    System.out.println();
    }

    5:数组复制

             int[] scores1 = {88,75,54,43,35,34,45,43,77};
            int[] scores2 = Arrays.copyOf(scores1,scores1.length);
    

    6:用构造函数对对象初始化流程封装
    class CashCard{
    String number;
    int balance;
    int bonus;
    CashCard(String number,int balance,int bonus){
    this.number=number;
    this.balance=balance;
    this.bonus=bonus;
    }

    }

    7:为对象操作流程封装
    import java.util.Scanner;

    CashCard[] cards ={
    new CashCard("Aoo1",500,0),
    new CashCard("B001",300,0);
    new CashCard("C001",1000,1);
    };

    Scanner scanner =new Scanner(System.in);
    for(CashCard card :cards){
    System.out.printf("为(%s,%d,%d)储值:",card.number,card.balance,card.bonus);
    card.store(scanner.nextInt());
    System.out.printf("明细(%s,%d,%d)储值:",card.number,card.balance,card.bonus);
    8:封装对象内部数据
    private String number;
    9:提供取值
    int getBalance(){
    return balance;
    }

    代码调试中的问题和解决过程

    不规则数组的规则:
    int[][] arr = new int[2][];
    arr[0] = new int[] {1,2,3,4,5};
    arr[1] =new int[] {1,2,3};
    for(int[] row : arr){
    for(int value : row){
    System.out.printf("%2d",value);
    }
    System.out.println();
    }

    其他(感悟、思考等,可选)

    总之积极主动写代码就可以了。
    

    学习进度条

    代码行数(新增/累积) 博客量(新增/累积) 学习时间(新增/累积) 重要成长
    目标 2000行 1篇 5小时
    第3周 200/300 2/2 20/20
  • 相关阅读:
    opstack 笔记 (一) 概念
    Redis学习汇总
    MongoDB添加删除节点
    Redis主从及Cluster区别及注意事项
    叶问18
    Redis慢日志取出来
    Redis的AOF重写脚本
    使用Python比较MySQL数据库中两个数据库的表结构--转载
    关于InnoDB存储引擎 text blob 大字段的存储和优化
    MongoDB进阶之路:不仅仅是技术研究,还有优化和最佳实践--转载
  • 原文地址:https://www.cnblogs.com/20145124cwm/p/5299400.html
Copyright © 2011-2022 走看看