20145331 Java Programming 3rd week of study summary

Source: Internet
Author: User

20145331 "Java Program Design" The 3rd week study summary textbook Learning content Summary

The fourth chapter of the Understanding Object

• Object: The specific entity that exists, with a definite state and behavior

• Class: A set of objects that have the same properties and behaviors, a mechanism for combining operations and properties common to each object

• Class-To-object relationships: To produce an object you must first define a class, the class is the design of the object, and the object is an instance of the class. I think that the description of the relationship between class and object is more vivid in the video, it says that class is the description of things in real life, and object is such thing, it is a real individual, moreover, by lifting the car example, we also have a deeper understanding of the class and object.

Java.util.scanner class: Java.util.Scanner the Nextint () method will look at the standard input, there is no input the next string (separated by a space or newline), some will try to parse it into the int type, the other nextbyte () and Nextshort () are similar in function. If you get the previous string directly (separated by a space or line break), use Next () and if you want to get the entire line of text entered by the user, use Nextline () (separated by a space or line break), in summary the scanner class greatly simplifies the Java input.

Java.math.bigdecimal class: Java adheres to the IEEE754 floating-point arithmetic specification, using fractions and exponents to represent floating-point numbers, which results in the inability to perform operations accurately, resulting in computational errors, such as 1.0-0.8, which is not 0.2. Therefore, if the accuracy is required, it is necessary to use the floating-point number carefully, and can not use = = directly compare the results of floating-point numbers, so we could use the BigDecimal class to get the desired accuracy.

• In Java, an array is an object, and Java needs to check the bounds of the array, which will trigger the arrayindexoutofboundsexception exception (this differs from the C language)

• In Java, strings are java.lang.String instances that are used to package character arrays.

Chapter Fifth Object Encapsulation

5.1 What is encapsulation

• Encapsulation (encapsulation) actually uses methods to hide the data of the class, control how much the user modifies and accesses the data, hide the object details, and manipulate the object as a black box.

5.2 Class Syntax details

this keyword

this represents the reference to the object to which the function belongs, in short, the reference to this class object, and we can use this when the object that calls the function is needed within the function.

this () represents the invocation of another constructor, as to which constructor is called, depending on the type and number of arguments given when this () is called.

Static keyword

Static is used to modify members (member variables and member functions), which are declared as static members, not to have individual objects owned, but to belong to classes. • The This keyword cannot appear in the static method and cannot be used with non-static data or method members.

Problems in teaching materials learning and the solving process

This code is not understood in the learning of arrays:

for (int score:scores) {

System.out.printf ("Student Score:%d%n", score);

}

After reading the textbook carefully, we find that the meaning of the above code can be interpreted as:

for (int i=0;i<scores.length;i++)

This enhanced for loop is easier, and his idea is that the above program fragment takes the first element of the scores array, assigns it to the score variable, executes the loop body, and so on, until all the elements in the scores array have been accessed.

Problems in code debugging and the resolution process

Here is the code I practiced (for 4 examples, the rest of the code is already hosted):

Other (sentiment, thinking, etc., optional)

The content of these two chapters is obviously more difficult than the previous, simple reading simply no clue, by asking other students and watching the corresponding video course on my help is very large, this habit is also maintained, can not easily be difficult to frighten.

Learning progress Bar
Lines of code (new/cumulative) Blog volume (Add/accumulate) Learning time (new/cumulative) Important growth
Goal 3500 rows 20 articles 300 hours
First week 150/150 1/1 14/14
Second week 150/300 1/2 14/28
Third week 100/400 1/3 14/42 Learn the managed code and learn how to construct the model to understand the knowledge of the class and object part.
Resources
    • Java Learning Notes (8th Edition)
    • Java Learning Note (8th Edition) Learning Guide

20145331 Java Programming 3rd week of study summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.