20165231 2017-2018-2 "Java Programming" 3rd Week study Summary

Source: Internet
Author: User

Summary of learning contents of textbook
    • Object: The specific entity that exists, with a definite state and behavior

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

    • Objects from a class: A class definition can be treated as a template for objects with similar attributes and common behavior that can be used to produce objects

    • Classes from objects: The generation of classes, from a few instances, to a large number of similar instances of the abstraction process (abstraction)

    • A class is a design diagram of an object that is an instance of a class that is defined first by the generated object.
    • The class member variable is valid throughout the class, and the local variable is valid only in the method.
    • The name of the local variable is the same as the name of the member variable, and the member variable is hidden.
    • Member variables have default values and local variables do not, so you need to declare their values before using local variables. (Note: Declaration and assignment are not equivalent to int a=12; not equal to int A; a=12;)

    • When there are multiple classes of class compound calls in a program function, it is possible to run the class with the main function after compiling, and other classes may appear to be a lot of rows, but only one method in the main program cannot run alone. For example, the textbook code:

Singgame.java

public class SingGame {  public static void main (String args[]) {    Line line=new Line();    line.givePersonScore();  }}

Inputscore.java

import java.util.Scanner;public class InputScore {  DelScore del;  InputScore(DelScore del) {    this.del=del;  }  public void inputScore(){    System.out.println("请输入评委数:");    Scanner read=new Scanner(System.in);    int count = read.nextInt();    System.out.println("请输入评委的分数:");    double []a =new double[count];    for(int i=0;i<count;i++){      a[i]=read.nextDouble();    }    del.doDelete(a);  }}

Delscore.java

public class DelScore {  ComputerAver computer;  DelScore(ComputerAver computer) {    this.computer=computer;  }  public void doDelete(double [] a) {    java.util.Arrays.sort(a);    System.out.print("去掉一个最高分:"+a[a.length-1]+",");    System.out.print("去掉一个最低分:"+a[0]+"。");    double b[] =new double[a.length-2];    for(int i=1;i<a.length-1;i++) {      b[i-1]=a[i];    }      computer.giveAver(b);    }  }

Computeraver.java

public class ComputerAver {  public void giveAver(double [] b) {    double sum=0;    for(int i=0;i<b.length;i++){      sum=sum+b[i];    }    double aver=sum/b.length;    System.out.println("选手的最后得分:"+aver);  }}

Line.java

public class Line {  InputScore one;  DelScore two;  ComputerAver three;  Line(){    three = new ComputerAver();    two=new DelScore(three);    one=new InputScore(two);  }  public void givePersonScore() {    one.inputScore();  }}

There are five class files at this time and should be run after compilation SingGame .

Problems in code debugging and the resolution process

Problem: When multiple classes in a program are not called each other, you want to have a single command to src automatically place the code in the folder after compiling it bin , and you will be prompted for the error to find the symbol.

Workaround: Create a new folder to put all the classes for this program, and then compile all the. java files for the folder by command.

Code Hosting

Sentiment

Learning to the fourth chapter, found that gradually began some difficulty, but also formally began to step into the Java program design. objects, methods and other content is an essential part of the general Java Program Design content, and practice more dozen code, will gradually understand its routines, so as to understand its use.

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 200/200 1/4 10/10
Second week 300/500 1/5 10/20
Third week 800/1300 1/6 20/40
Week Four
    • Planned study time: 20 hours

    • Actual learning time: 20 hours

    • Improved situation:
      Multi-Tap Code

Resources
    • Java Learning Notes (8th Edition)

    • Java Learning Note (8th Edition) Learning Guide
    • Java Programming Video

20165231 2017-2018-2 "Java Programming" 3rd 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.