20165210 Java Third Week study summary

Source: Internet
Author: User
Tags float max instance method

20165210 Java Third Week study summary of learning Contents-fourth Chapter study Summary
    1. Several development stages of programming languages:
    • For machine language
    • Process-oriented language
    • Object-oriented language
    1. Class:
    • class declaration:
class People {    ...}class 动物 {    ...}
    • Class Body:
class People {    类体的内容}class 动物 {    类体的内容}
    • Member variables:
1. 类型:class Factory {    float [] a;    Workman zhang;}class Workman {    double x;}2. 有效范围:成员变量在整个类内都有效,其有效性与它在类体中书写的先后位置无关。3. 方法:方法头 {    方法体的内容}
    • Construction method and object creation
    1. Construction Method:
Lader() {    }
    1. To create an object:
类的名字 对象名字;
    1. Working with objects:
对象。变量;
    • The basic structure of classes and programs:
    1. The Java source files involved in the application are saved in the same directory, compiled separately, to get the bytecode files required by the Java application.
    2. Run the main class.
    • Parameter Passing value
    1. Value-Transfer mechanism
    2. The value of the basic data type parameter
    3. Value of reference type parameter
    4. Variable parameters:
例:public void f(int ... x)public void g(double a,int ... x)public void method(int ... x,int y)
    • Combination of objects:
    1. Combination and Reuse:
      If an object a combines object B, then object A can delegate object B to call its methods, that is, object A to reuse the method of object B in a composite way.
    • Instance members and class members:
    1. Declaration of instance variables and class variables
class Dog {    float x;    static int y;}
    1. The difference between class variables for instance variables
1. 不同对象的实例变量互不相同2. 所有对象共享类变量3. 通过类名直接访问类变量
    1. Definition of instance methods and class methods
class A {    int a;    float max(float x,float y) {        ...    }    static float jerry() {        ...    }    static void speak(String s) {        ...    }}
    1. The difference between an instance method and a class method
1. 对象调用实例方法2. 类名调用类方法3. 设计类方法的原则
    • Method overloading
    1. Syntax rules for method overloading
      Meet the conditions:
- 参数的个数不同- 参数个数相同,但参数列表中对应的某个参数的类型不同
    1. Avoid any ambiguity in overloading
class Dog {    static void cry(double m,int n) {        System.out.println("小狗");    }    static void cry(int m,double n) {        System.out.println("small dog");    }}
    • this keyword
    • Package
    1. Package statement:
package 包名;
    1. Storage directory for classes with package names
package tom.jiafei;c:\1000>javac tom\jiafei\源文件
    1. Run the main class with the package name
c:\1000>java tom.jiafei.主类名
    • Import statement
    1. Introduction of classes in class libraries

      import java.until.*;(引入java.until包中所有的类)import java.until.Date;(引入java.until包中的Date类)
    • Object array
      Use an array of objects, that is, the elements of an array are objects:
Student [] dtu;dtu = new Student[10];
Problems encountered in learning and their solutions
    1. I don't quite understand what this keyword is for in my study.
    2. Is there a package statement that must be placed in the folder after the package to compile? Could you not set up that folder?

      Code Hosting

Sentiment

This week's code is much longer than last week, but through this week's study mastered some of the use of keywords, and I think the object array is a very important content, but also learned the package statement, this week is still very fruitful

20165210 Java Third Week 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.