20165235 Qi Ying 2018-3 "Java Programming" third week study summary

Source: Internet
Author: User

20165235 Qi Ying 2018-3 "java program design" The third week of learning summarize the contents of learning Content Summary class and Object Learning Summary
  • Class: Java has three features as an object-oriented language: ① encapsulation. ② of inheritance. ③ polymorphism. The class in Java is the basic feature, and the variable declared by the class is called an object. A function called method that defines a body in a class.
  • The basic structure of classes and programs: (a) Construction method: When creating an object, the constructor method has the same name as the class, and there is no type. You can create a construction method, but make sure that the number of parameters is different or the parameter types are different. (ii) Use the new character when assigning variables to objects. Use "." operator to manipulate the object. (c) Java has several classes that can be in a single source file or in several folders.
  • Parameter value: (a) The value of the parameter in the method: The value of the argument variable is the caller-specified worthy copy.
  • Combination of objects: A class can use an object as its own member variable. An object A combines object B, then a can delegate B to call its method, that is, object a uses the method of the B in a composite way.
  • Instance members and class members (i) precede variables or methods with static called class variables, otherwise called instance variables. (b) Difference: the instance variables of different objects vary, and all objects share class variables, which can be accessed directly through the class name. (c) Class methods can only invoke class variables, and instance variables may invoke class variables or instance variables.
  • Method overloading: (a) Definition: A class can have multiple methods with the same name, but it is guaranteed that the parameters of these methods are different or the parameter types are different. (b) Call an overloaded method that refers to an overloaded method that calls the same type of argument to be explicit, corresponding to parameters of the same type.
  • This keyword: (a) The This keyword represents an object. (b) This may not appear in a class method, and this can be changed to a class name in a class method.
  • Package: Packages A package of several source files in a folder, you can effectively manage the Java files.
  • Import statement: (a) The function of the statement is to introduce the class in the package. (b) The Java.lang package is the core statement of the Java language and does not require import statements, including "System class, Math class". (c) If the class within the package is not imported with import, you can use the class directly with the package name. (iv) Methods and member variables modified with private,public,protected have certain access rights. (v) Javadoc file name. Java generates an HTML document in the directory that can be viewed in a browser.
  • JRE extension with jar file:/jre/lib/ext, as long as the class is packaged into a jar file and placed in ext, the program can use the import to use the classes in the extension.

    Problems in teaching materials learning and the solving process
  • Question 1: In the textbook 78 page There is a code, why Chinese characters can also be used as variables, Chinese characters in the Java language is not as Unicode encoding exist?
  • Question 1 Solution: Search the Internet for answers: Java supports Chinese class names, method names, property names, and does not cause run-time links to fail because of garbled characters. This is determined by the Java Kernel Support UTF-8 feature. However, this usage is not supported in the Java language specification. See Java in Chinese name
  • 2: Can I only guarantee that the return type is different when I overload a method?
  • Problem 2 Solution: Search the Internet for answers: method return types do not participate in operations and comparisons, so it is also guaranteed that the method parameters are different, or the parameter types are different.

Problems in code debugging and the resolution process
    • Issue 1: "No symbol errors found" occurs at compile time for a class with the Main method, but the code itself has no syntax errors.
    • Problem 1 Solution: After learning the package statement, I package the source files associated with package Java_pack.pack_1 it and compile the source files at the same time javac bin/Java_pack/pack_1/*.java so that no errors occur. And then enter java -cp .:bin Java_pack.pack_1.文件名 .
      Here is the package file directory that I created in Unbuntu:
Code Hosting

Learning sentiment

I benefited a lot from this week's learning, from classes to creating objects and calling methods, which made me feel the power of Java as an object-oriented language, but what really made me feel strong was Java's vast library of libraries, such as Java.lang,java.until, which provided us with many algorithms. Unlike the C language, the C language is a very simple algorithm such as sorting to find and so have to write their own algorithm, and Java can be called through the import statement of the algorithm in the class library. In fact, I think that the C language structure and Java classes have the same effect, C language has a structure array, and Java has an object array, are in the array to hold a struct or object. But the difference is that the struct in C is only for itself, and the classes in Java are for all objects, and different source files can invoke classes from different source files.

Learning progress Bar
lines of code (new/cumulative) Blog Volume (Add/accumulate) Learning Time (new/cumulative) Important Growth
Goal 5000 rows 30 Articles 400 hours
First week 31/200 1/2 12/20 Git uses
Second week 404/500 3/4 24/38 Java Basic syntax
Third week 920/1000 4/7 52/60 Classes and objects and packaging
Resources
    • Java Learning Notes (8th Edition)

    • Java Learning Note (8th Edition) Learning Guide

20165235 Qi Ying 2018-3 "Java Programming" third week study summary

Related Article

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.