20165223 Java programming Second week of study summary

Source: Internet
Author: User
Tags array length float double hosting

20165223 "Java program design" the second week to summarize the learning contents of teaching materials Summary Chapter II essentials
    • Identifiers and Keywords
    • Basic data types
    • Type conversion Operations
    • Input/Output data
    • Array
Chapter III Essentials
    • Operators and expressions
    • Statement overview
    • If conditional branching statement
    • Switch Switches statement
    • Looping statements
    • Break and Continue statements
    • Arrays and for statements
Problems in teaching materials learning and the solving process
  • Identifiers and Keywords
    • Identifier = name: composed of letters, underscores, $, numbers, the length is unrestricted; the first character cannot be a numeric character; it is case-sensitive; cannot be a keyword; cannot be true, false, NULL
    • Language used in Java: Unicode character set
    • keywords (need to memorize): 50
  • Basic data types
      • Logical Type: Boolean
        • True, False
      • integer type: Byte, short, int, long
        • Note each type of byte memory, In case of overflow
          | integer type | constant | variable BYTE memory | Variable Value range |
          |:-:|:-:|:-:|:-:|
          |int type | Various binary integers |4 (32-bit) |-2^31~2^31-1|
          | BYTE type | Not present in | | (8-bit) |-128~127|
          |short | There is no single (16-bit) |-2^15~2^15-1|
          |long Type | suffix L |8 (64-bit) |-2^63~2^63-1|
        • long type constant must be used after L
      • character type: Char
        • differs from C : Char is unsigned and cannot be declared with the unsigned modifier
      • floating-point type: float, double
        • float constant must to have suffix f or F
        • Doub Le constant suffix d or D can omit
      • type conversion Operations
        • does not include logical types
        • Precision Arrangement (low to High): byte short char int long float double
        • the system automatically transforms when assigning a value from a low level to a high-level variable
        • to cast a value from a higher level to a low-level variable: (type name) the value to convert
        • integer defaults to int type, decimal default is double type
  • Input/Output data
    • Input
      • Create a Scanner object:Scanner reader = new Scanner(System.in)
      • The scanner object calls the method to read the data entered by the user's keyboard (wait):reader.nextInt()
    • Output
      • Line break:System.out.println();
      • No Line break:System.out.print();
      • System.out.println();and System.out.print(); output string values, expression values, using the collocated symbol + to make the input serial output
      • function output similar to C:System.out.printf("格式控制部分",表达式1,表达式2,……,表达式n);
      • Format Control Section = Format Control symbol %d、%c、%f、%s + normal character
  • Array
    • Declaring an array:类型 [ ] 数组名;
    • To create an array:数组名 = 类型 [整数值]
    • Array Length:
    • 数组名.length
    • A single-dimensional array that represents the number of array cells; The number of one-dimensional arrays in a two-dimensional array
    • Array Reference : The value stored in the array variable is the reference to the array. Arrays use subscript operations to access their own cells. Arrays of the same type have the same cell once they have the same reference.
Problems in code debugging and the resolution process
  • Example2_1.java
    • javacWrong hit java , resulting in an inability to compile

    • Compile at the wrong directory, should be compiled under the main folder, the use javac -d bin src/Example2_1.java of code. Because only in the home folder Java can find the bin folder correctly, put the *.class file into it.

  • Example3_9.java
    • VI Edit the code wrong will be System.out.printf hit System.out.println , prompted the error:
    • Correctly recognize the omission and completion of the knowledge points of input and output in Chapter two:
      • Format:System.out.printf("格式控制部分",表达式1,表达式2,……,表达式n)
      • Format Control Section = Format Control symbol %d、%c、%f、%s + normal character
      • Normal character output, format symbol output expression value
  • in the process of committing the code git commit error file
    • reference data revocation git commit error file, combined with the students in the blue ink cloud in the code to help, The problem was resolved successfully
    • git Add. and git commit How to fix the error file:
      • View nodes first: git log
        • commit xxx
        • Li>merge:xxx
        • author:xxx
        • date:xxx
      • find required commit_id
      • then: git reset commit_id
    • Also at the time of git push :
      • fallback to previous Commi T node, keep the modified code: git reset commit_id
      • falls back to the previous commit node, and the code returns to the previous step: git reset–hard commit_id
  • compile and run the code with the package
    • method One (not recommended):
      • Open a *.java file with VI, enter the package-related code: the first line of input PA Ckage < package name; , then write the code normally
      • new Package folder: mkdir < package name;
      • compilation: javac *.java
      • Move code file into package: MV *.class < package name;
      • run: Java < package name >.< main class name;
    • method Two (recommended):
      • Open a *.java file with VI, enter the package related code: First line Enter package < pack name; , and then the normal code
      • compiles to bin: javac-d bin *.java
      • run in package: JAVA-CP Bin < package name >.< main class name ;
    • where method two -cp refers to Classpath, indicating path bin
  • Code Cloud Submission Job method
    • To create the Docs directory:mkdir docs
    • Create an empty markdown file such as "JAVA_HOMEWORK_WEEK1.MD":touch docs/java_homework_week1.md
    • Put the homework blog into version control: git add . ,git commit -m "init docs with empty java_homework_week1.md"
    • Push the job to the code cloud:git push
    • Click on the Docs folder on the code cloud, open "java_homework_week1.md" and click "Edit" to write your homework.
    • The commit description is "copy job Template", which is equivalent to git commit-m "copy job Template", click "Submit to Master" button to commit the job
    • Sync documents written on the code cloud to your computer:git pull
    • Run the script "statistics.sh" and learn the progress:./statistics.sh
    • Complete this week's learning task and run the git push week to push the results to the code cloud
Code Hosting

See Code Cloud Code Link: https://gitee.com/BESTI-IS-JAVA-2018/20165223cn.git

Last week's summary of the wrong quiz

See blog: Week2 Test and summary

Feeling and thinking

This week learning task is the second chapter, obviously compared to the first week to feel the progress of learning, in the copy code while constantly practicing memory, the knowledge points have mastered. After two weeks of classes have begun to adapt to the pace of the class, but also understand that they need to do more practice under the class. This week's first Test due to my lack of knowledge about package packages and the error of submission time lead to the failure to submit the results of the second Test on time, clearly felt their shortcomings, wrote a blog Week2 test and summary of the analysis and summary, Also reminds me to be more serious to listen to and go to practice, can in exams and class.

Learning progress Bar
lines of code (new/cumulative) Blog Volume (Add/accumulate) Learning Time (new/cumulative) Important Growth
Goal 3000 rows 30 Articles 400 hours
First week 178/200 1/2 20/20
Second week 200/200 2/2 20/20
Resources
    1. Chapter II Teaching Video
    2. Code Hosting
    3. The easy use of the code cloud and the blog park
    4. Undo Git Commit Error file

20165223 Java programming Second 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.