• 20182331 2019-2020-2,3《数据结构与面向对象程序设计》第2,3周学习总结


    20182331 2019-2020-2,3《数据结构与面向对象程序设计》第2,3周学习总结

    一、教材学习内容总结
    (一)、第二章学习总结:
    1.字符串是由String类定义的对象
    2.println输出后光标移动到下一行,print不会
    3.变量常量及他们的赋值
    4.基本数据类型,和C的没啥差距
    5.5个算数运算符及其优先级和自增自减,赋值运算符
    6.数据类型转换:赋值类型转换、提升类型转换、强制类型转换
    7.Scanner类提供一些从不同数据源读取各种类型数据的方法
    (二)、第二章学习总结:
    1.创建对象引用变量的声明与初始化以及别名的概念
    2.String类对象的长度和内容不可修改
    3.包:JAVA标准类库中的类,import声明
    4.Random类用来生成随机数
    5.Matn主要是基本数学函数,静态方法
    6.NumberFormat和DecimalFormat格式化信息输出,printf输出含有数值的格式字符串
    7.一个包装器代表一种具体的基本数据类型

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

    问题1:静态方法和非静态方法有啥区别?
    问题1解决方案:两者的生命周期不同。静态方法的生命周期跟相应的类一样长。而非静态方法的生命周期和类的实例化对象一样长。静态方法可以直接调用,类名调用和对象调用。但是非静态方法只能通过对象调用。
    问题2:Scanner scan = new Scanner(System.in)经常用但是它是啥意思?
    问题2解决方案:调用Scanner类的方法,必须创建一个对象。Java中的对象使用new运算符来创建。

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

    问题1:使用Scanner类输入数据时发生错误,提示InputMismatchException
    问题1解决方案输入类型与方法不匹配,将输入语句修改成与变量类型对应就可以了
    问题2::吃回车问题
    问题2解决方案:当要输入字符或字符串时,如果前面不是字符或字符串类型的输入,那么就会出现吃回车问题,输入op=scan.nextLine(),将前者留在键盘缓冲区的回车吃掉

    四、代码托管

    五、上周考试错题总结

    1.If you want to output the text "hi there", including the quote marks, which of the following could do that? (如果你想输出文本"hi there",包括引号在内,下面哪个语句可以做到?)
    A . System.out.println("hi there");
    B . System.out.println(""hi there"");
    C . System.out.println(""hi there");
    D . System.out.println(""hi there"");
    E . none, it is not possible to output a quote mark because it is used to mark the beginning and ending of the String to be output (无,不可能输出引号,因为它被用来标记字符串的开始和结束)
    原因:”是一个转义序列,用于在字符串中放置引号,因此这里使用它来输出引号和字符串的其余分。
    2.In order to compare int, float and double variables, you can use <, >, ==, !=, <=, >=, but to compare char and String variables, you must use compareTo( ), equals( ) and equalsIgnoreCase( ).
    A . true
    B . false
    原因:第一个我知道,但第二个和第三个我不知道
    3.You cannot cast a String to be a char and you cannot cast a String which stores a number to be an int, float or double. (你不能将字符串强制转换为char类型,也不能将一个字符串强制转换为int、float或double类型。)
    A . true
    B . false
    原因:根据实验二输入加减运算符的推断做的,但是我没搞清转化和取第一个字符的区别
    4.Which of the following is true regarding the mod operator, %? (关于求余运算符%,下面哪项是正确的?)
    A . It can only be performed on int values and its result is a double (它只能执行int类型的数值,其结果是double类型的数)
    B . It can only be performed on int values and its result is an int (它只能执行int类型的数值,其结果也是int类型的数)
    C . It can only be performed on float or double values and its result is an int (它只能执行float或者double类型的数值,其结果是int类型的数)
    D . It can only be performed on float or double values and its result is a double (它只能执行float或者double类型的数值,其结果是double类型的数)
    E . It can be performed on any numeric values, and the result always is numeric (它可以执行任何类型的数值,其结果始终是数值)
    5.What is output with the statement System.out.println(x+y); if x and y are int values where x=10 and y=5? (如果x和y是int类型的数值,x=10,y=5,那么语句System.out.println(x+y);的输出是什么?)
    A . 15
    B . 105
    C . 10 5
    D . x+y
    E . An error since neither x nor y is a String (因x和y都不是字符串而引起的一个错误)
    6.What is output with the statement System.out.println(""+x+y); if x and y are int values where x=10 and y=5? (如果x和y是int类型的数值,x=10,y=5,那么语句System.out.println(""+x+y);的输出是什么?)
    A . 15
    B . 105
    C . 10 5
    D . x+y
    E . An error since neither x nor y is a String (因x和y都不是字符串而引起的一个错误)
    7.If you want to store into the String name the value "George Bush", you would do which statement? (如果你想把"George Bush"这个值存储为字符串类型的名字,你会执行那条语句?)
    A . String name = "George Bush";
    B . String name = new String("George Bush");
    C . String name = "George" + " " + "Bush";
    D . String name = new String("George" + " " + "Bush");
    原因:4、5、6、7都是因为基础只是不扎实而做错的
    其他没贴出来的错题一部分是重复问题,一部分是由于英语不好

    六、结对互评
    20182309 结对学习内容
    结对学习内容:
    重装Linux
    替换vimrc
    切换源
    比较C语言和Java
    帮助分析错误

    董其鹏: 因为我两是上下铺的关系,所以我们是一起学习,有问题一起查资料,一起解决,虽然他的基础不好,但是他学的十分努力,出了bug先是自己解决,解决不了在过来和我商量。

    七、学习进度条

    代码行数(新增/累积) 博客量(新增/累积) 学习时间(新增/累积) 重要成长
    目标 5000行 30篇 400小时
    第一周 729/838 2/4 47/67

    《Java程序设计与数据结构教程(第二版)》

    《Java程序设计与数据结构教程(第二版)》学习指导

  • 相关阅读:
    数据库回滚解决删除数据库出错
    教大家支付宝抢红包
    MySql 连接字符串
    搭建Git服务器
    队列的顺序存储结构
    栈的应用---递归
    栈的链式存储结构及应用(C、Java代码)
    栈的顺序存储结构及应用(C、Java代码)
    静态链表、循环链表、双向链表(C代码实现)
    线性表的链式存储结构(Java代码实现)
  • 原文地址:https://www.cnblogs.com/gao-kuanrang/p/11567646.html
Copyright © 2020-2023  润新知