20,182,308 Hua Luo Han 2019-2020-1 "data structures and object-oriented programming," the second and third week learning summary

Learning content summary

1, note that the input point Scanner class and some common commands - such as x = scan.nextLine; x = scan.next (), etc., and the content may be introduced to contact the back of the single character input command, i.e., x = scan.next () .charAt (0).

2, String class variety of commonly used commands, in particular String substring (0,5) (the first to fourth output string consisting of a character string). It is easy to find a method of the String class command and C language here among the string-related commands have much in common.

3, import quoted statement, Random class, formatted output were focused on learning, a little understanding of some of the Math class, view the relevant details about the method of packaging.

Textbook learning and problem-solving process

One problem: on the issue of random numbers - if you want to select any number less than 10 to 20, including both floating-point numbers, how to be more appropriate programming it?

A problem-solving process: first to recognize that, if it comes to floating-point numbers, then we must use Random.nextFloat () method and the method without Random.nextInt () of. Considering that range, and therefore the finally selected such :( default string of codes has been completed Import)

float x;
Random ran = new Random();
x = ran.nextFloat()*10+10;

Second problem: a problem of earlier - on Scanner, every time you need to enter a Scanner or a class inside as long as a Scanner?

Second problem solving process: a general class as long as a Scanner. Scanner nature is also like a variable, like the C language scanf statement among the same. But I understand it seems, Java method in the scanner as the C language code like this:

int x;
scanf("%d",&x);

But the scanner can be entered in any of our common data, each input is first initialized to a Scanner.

int m;
double a,b;
Scanner scan = new Scanner (System.in);
m=scan.nextInt();
a=scan.nextDouble();
b=scan.nextDouble();

This is what I have to be modified according to the textbook section of the code, we can see inside the scanner what type of data, depending on which it is given to the type of data.

Code debugging and problem solving in the process

One problem: You can not enter a single char type data.

A problem-solving process: Find a Baidu know about the content (links at the end of the text has been placed in Resources). Books also raised about the content, that content P47-3.2 in: char charAt (int index), returns the character at the specified index of.

Question two: in the classroom practice Bookshelf.java job, regardless of how the right kind of book can not output data.

Second problem solving process: determining the referenced class--book.java front part there is no problem, Bookshelf.java no problem. After confirming the sister, sister school told to use tostring System.out.println method called in. After investigation found the book, this approach means "return the text in the way", that method toString, which name should not make a change.

[Managed code] ( https://gitee.com/besti1823/20182308IZUMO )

Last week exam wrong question summary

:( wrong question a second exam week) 12, which is the main method JAVA defined by the __.

答案:public static main(String[] args)

Reflection: knock code is still visible enough. The main method is more like the original main function among a C language program.

Wrong question two:

Reflection: First, can now be determined, along with the println behind something () can be used to output the screen, + has played a role in the connection. In it presumably to distinguish between two different types of digital int, so automatically by a space.

 (Third week of the exam for the first time)

Pair peer review and

Worth learning problems or blog:

The contents of the blog is very simple, and all the problems are very real confusion reflects learning in two weeks. But this problem is not more than can be met with the person and not able to do while recording found the problem while the problem of learning good habits for two weeks. If not write a blog, the draft does not exist, you can also try a laptop,

Code is worth learning or problem:

Programmed with convenient way appreciated, methods. But the problem with these is that the foundation, facilitate understanding of the method, such that the entire code is very rigid, and seemed more jumbled, can modify a small room.

Based on score, I give this blog Rate: XX points. Scores as follows: 14 minutes

Proper use markdown syntax (1)

Complete elements (1) template

Textbook learning and problem-solving process (2)

The code debugging and problem solving process (2)

This week more than 300 branches of valid code (2)

Feelings, experience does not leave large empty (1)

There are hands-on writing new code (1)

Comments seriously, can point out problems and blog code (1)

Knot authentic (1) of learning

Comments had students blog, and code

Pair this week learning

[20182312]()

Pair Photo

Pair learning content

1、重点学习了第三章中课堂涉及内容,复习了有关String方法的有关内容。如何连接两个字符串、如何截取字符串中的内容、如何选取字符串中的某个字符转换成char型的变量。我们对这些问题进行了比较多的沟通交流和共同实践。

2、接上条。我们也加强沟通了格式化输出的有关内容,我与12号同学讲解了DecimalFormat方法的使用情况(也就是对输出数字的小数位有要求时),并得出了这样的方法要比C中printf控制输出数字要来得方便、稳定。同时12号同学同我讲解了封装的一些思想、NumberFormat的使用环境。

3、与结对同学共同交流完成了课本中课后作业留下的习题。

 

上周博客互评情况

[20182312](https://www.cnblogs.com/shouko/p/11503986.html

其他

1、在这两周中我们将目光从原本的Linux系统转变到了Vim上来,更多关注了Java程序的编写。同时王sir也明显放慢了讲课的速度,并且强调要我们课后去学习,并告诉了我们Java语言和C语言存在相当多的相通之处。比如在数据类型方面,但是也有不同的方面——比如作为面向对象的Java语言,对于String类型的数据显然更容易输入、保存和编辑,而对于单个字符的输入和编辑,就不如C来得简便。

2、作为面向对象的JAVA,已经有了许多便利的方法和类。使用类的方式和C中使用函数类似。但是做实验时候我的教训告诉我:一定要检查每一个类中的可能错误,在一个需要运行多个方法的大class中,如果有一个小class出现了错误,那么就会导致整体的巨大问题。尤其是对于有输出值的class,一定要class内部是否给予了可输出的数据。

 

学习进度条

  代码行数(新增/累积) 博客量(新增/累积) 学习时间(新增/累积) 重要成长
目标 10000 30 400h  
第一周 101/101 2/2 23/23

了解了一些Linux系统操作入门、

学会了基本的JDB调试操作

第二、三周 353/441(删除了一些代码) 3/5 42/67

能够基本记住Java代码编程中的格式代码。

了解了一些有关方法的特殊命令(比如substring)

了解了一些有关类的基本知识。

 

参考资料

1、Java toString方法

2、Java怎么接收char类型的数据?

Guess you like

Origin www.cnblogs.com/77599aa/p/11568283.html