20165233 Java second to third chapter study summary

Source: Internet
Author: User

2017-2018-2 "Java program design" The second week study summary textbook study summary

Second to third chapter

Ch2
    • Identifiers and Keywords
    • Basic data type:
    • Logical Type: Boolean
    • Integer type: int, byte, short, long ( Note: A long constant is represented by the suffix l; and there is no unsigned declaration in Java )
    • Character type: Char
    • Floating-point type: float, double (must have a suffix F or f after the float constant)
      )
    • Type conversion Operations
    • Input and output data
    • Array
Ch3
    • Operators and expressions
    • If conditional branching statement
    • Switch Switches statement
    • Looping statements (including for statements, while statements, do-while statements)
    • Break and Continue statements
    • Iterating through an array in a simpler way: for (declaring a loop variable: the name of the array)
Problems in teaching materials learning and the solving process
    • 1: Under what circumstances do I need to enter import java.util.Scanner ?

    • Problem 1 Solution: This is the statement of the console dynamic input,
      System.out.println("请输入一个数字:");
      Scanner scan=new Scanner(System.in);
      a=scan.nextInt();
      System.out.println(a);
      When you need to assign a value to a variable, you can use it!

Problems in code debugging and the resolution process
    • Issue 1: In-Class code compilation run test process, javac -d bin Hello.java error "File not found".
    • Issue 1 Solution: Because the Hello.java file is located src in a folder, the correct command line should be javac -d bin src/Hello.java .

    • Question 2: Chapter Three example example3_8 the result of the final output of the program, the result of the string output is the corresponding position number, not the character, why do you have such a result?

    • Problem 2 Solution: In the position of the output statement, the for(char ch:b) careless will be char hit, the int type cast.
Code Hosting

Last week's summary of the wrong quiz
    • Error 1: Classroom code compilation run test with package

    • Create directory structure: Use mkdir 20165233 ,, and mkdir src mkdir bin build the required directory structure.

    • Packaged:package is5233

    • Compile: javac -d bin src/Hello.java , due to the topic required to put the Hello.java file intosrc
      folder, so yes src/Hello.java . To put the compiled bytes into a bin folder is used -d .

    • Run: To java -cp .:bin is5233.Hello run in the folder where the bytecode file is placed.

Reason: The contents of the previous lesson are not mastered, now fully understood and will be proficient in using these statements.

Other (sentiment, thinking, etc., optional)

The second to third chapter of knowledge is the basis of learning Java, has learned the C language for this part of the knowledge to grasp more easily. But in the course of learning, there are some points of knowledge that are not quite the same as C language. For example, there is no use of unsigned declared variables in Java, [] and you cannot specify the number of array elements in the array. So you should pay particular attention to the details of the study, otherwise it is easy to make mistakes.

20165233 Java second to third chapter 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.