2017-2018-2 semester 20172324 "Java Program design" Sixth Week study summary

Source: Internet
Author: User

20172324 "Java program design" The sixth Week study summary textbook Learning content Summary
    • How to create an array and the difference between int[] X and int x[] (compile-time is no different, only the former is consistent with other types of declarative methods)
    • Each of the Java arrays is an iterator.
    • An array is passed as a parameter to a method, and actually a copy of the original array reference is passed.
    • Object Array (base data type + object)
    • The previous index value in the two-dimensional array represents the row, and the other index value represents the column.
    • Variable-length parameters with ...

      Problems in teaching materials learning and the solving process
    • Problem 1:family code in String...name the ... What is the meaning.
    • Problem 1 Solution: This is a new feature of jdk1.5: variable-length variables. This means that you can pass in any number of parameters. More flexible than using data, there are some exceptions such as array out of bounds. Such as:
      getType(String...values);Call, can getType("a","b","c") wait, the number of arguments is not limited, the type is the preceding string type. (hehe, I've seen some of the original books.)

    • Question 2:pp8.3 I'm a little confused. is upper[current-' A ']++ there, what exactly is added 1?
    • Issue 2 Solution: I can only write the comments step in.

for(int ch=0;ch<line.length();ch++)        {            current = line.charAt(ch);//定义current是输入的字符串从索引0开始的字符            if(current>=‘A‘&&current<=‘Z‘)//这里和Unicode有关,如果这个大写字母在A`Z之间                upper[current-‘A‘]++;//那么current-‘A‘就代表索引处那个特定的字符,索引处的值加1(最开始是0,因为没有出现过)            else                if(current>=‘a‘&&current<=‘z‘)//同上嘛,就是小写的而已。                    lower[current-‘a‘]++;                else                    other++;        }        
Problems in code debugging and the resolution process
    • problem 1:pp8.1, I began to want to define an array, put the value I want to enter by size into the index, the value does not appear to use 0 to fill, and if the same value, the number of numbers in the index value is increased by 1, and later found that an index can only put a value, there is no same number placed in the same index Case Cause I don't care what the input value output is all 0.
    • Problem 1 Solution: = = Use a two-dimensional array = =. The first step is to create two arrays containing the 0~50 51 numbers, one for the number you enter, and one to calculate the number of values for the same number in different indexes in the previous array. The second part uses the scanner method to enter the number you want to enter, and place them in the array A. The third step is to calculate the number of values you have entered, and to define an initial value of 0, and in the range of input values, the same value in the array b corresponding position increases the number of occurrences. The fourth step outputs the 51 numbers from 0 to 50 and the frequency at which you enter the number. The
    • problem 2:pp8.5 How to indicate that a number continues to be entered.
    • Problem 2 solution: In the book fifth chapter mentioned, string A string, and then defined as Y, the use of the string is equal, that is, equalsignorecase () This comparison, decide whether to continue the input.
    • Question 3: Continue to the previous issue ... I keep looping on the question "whether to continue typing", and I can't get the input data.

    • Problem 3 Solution: Write the same string as the fifth chapter of a STR, but also a string defined as "Y" of the another value, but in fact, in this chapter does not need STR to enter a palindrome. So define a another, otherwise it will be like me .... In fact, I still do not understand, I go to see the book.

String another = "y";//创建一个字符串命令它表示为y    int[] list = new int[50];//可以放50个数的数组        //创建一个可以连续输入数字的循环        while(another.equalsIgnoreCase("y"))//哦~这里的another要和下面输入的another做比较        {            Scanner scan = new Scanner(System.in);            System.out.print("是否继续输入(y/n): ");            another = scan.nextLine();//就是这里的            if (another.equalsIgnoreCase("y") )//another输入为y就可以输入数据,所以不需要多的字符串。            {                System.out.print("Enter your number: ");                number = scan.nextInt();                list[i] = number;                i++;            }        }
    • Problem 4:pp8.6 is a big problem, no solution ...

# # code Hosting

(run result of statistics.sh script)

Last week's summary of the wrong quiz
    1. The idea, program instructions execute in order (linearly) unless otherwise specified through a conditional Statement is known as
      A. Boolean execution
      B. conditional statements
      C. Try and catch
      D. sequentiality
      ==e. Flow of control==
      Control flow describes the order in which instructions are executed. It defaults to linear (or continuous), but is changed by using control statements such as conditions and loops.
    1. Which of the sets of statements below would add 1 to x if x are positive and subtract 1 from X if x is negative bu T leave x alone if x is 0?
      A. if (x > 0) x + +;
      Else x--;
      ==b. if (x > 0) x + +;
      Else if (x < 0) x--;==
      C. if (x > 0) x + +;
      if (x < 0) x--;
      Else x = 0;
      D. if (x = = 0) x = 0;
      Else x + +;
      x--;
      E. x + +;
      x--;
      If x is a positive number, X + + is performed with a negative x, otherwise, nothing happens, or x is not affected. In a, C, D, and E, the logic is incorrect. In a, X is done if x is not positive, so if X is 0, X becomes-1, which is the wrong answer. In C, if X is a positive number, it performs x + +. In either case, the next statement is executed, and if X is not negative, the ELSE clause is set to 0. Therefore, if X is a positive number, it becomes 0 after this set of code. If x is not 0, it is executed in D, X + +, and X. In E, this code does not attempt to determine whether X is a positive or negative number, it adds only one, and then subtracts 1 from X, making the x the same.
    1. assume, Count is 0, and Max is 1. The following statement would do which of the following? if (count! = 0 && total/count > max) max = Total/count;
      ==a. The condition short circuits and the assignment statement are not executed==
      B. The condition short circuits and the assignment statement are executed without problem
      C. The condition does not short circuit causing a division by zero error
      D. The condition short circuits so, there are no division by zero error when evaluating the condition, but the assignment Statement causes a division by zero error
      E. The condition would not compile because it uses improper syntax
      because the count is 0, (count! = 0) is false. Because the left-hand side of the & & condition is false, the condition is short-circuited, so the right-hand side is not counted. Therefore, a potential division error is avoided. Because the condition is false, the statement max = total/count is not executed, again avoiding potential division to zero error.
    1. Which of the following is true statements about check boxes?
      A. They may checked or unchecked
      B. Radio buttons is a special kind of check boxes
      C. They is Java components
      D. You can control whether or not they'll be visible
      ==e. All of the above==
      Each of the four statements about a check box is true.
    1. When comparing any primitive type of variable, = = should always is used to test to see if the values are equal.
      A. True
      ==b. false==
      This is correct for int, short, byte, long, Char, and Boolean, but cannot be a double variable or floating-point function.
    1. might choose to use a switch statement instead of nested if-else statements if
      A. The variable being TES Ted might equal one of several hundred int values
      ==b. The variable being tested might equal one of only a few int Val ues==
      C. There is or more int variables being tested, each of which could is one of the several hundred values
      D. There is, or more int variables being tested, each of which could is one of only a few values
      E. None of the Abov E, you would never choose to use a switch statement on place of nested IF-ELSE statements under any circumstance
      only in the test order Variable and it is an integer type (int or char in Java), the switch statement can be used.
    1. IF A switch statement is written this contains no break statements whatsoever,
      A. This was a syntax error and an appropriate error message would be generated
      B. Each of the case clauses'll be executed every time the switch statement is encountered
      C. The equivalent to have the switch statement always take the default clause, if one is present
      D. This isn't a error, but nothing within the switch statement ever'll be executed
      ==e. None of the above==
      While writing such a switch declaration is unusual, it is perfectly legal. The general rule that the toggle statement executes applies a matching case clause that executes after the switch expression is computed. Subsequently, all subsequent clauses are executed sequentially because there is no interrupt statement to terminate the switch/Case execution.
    1. The statement if (x < 0) y = x; else y = 0; Can be rewritten using a conditional operator as
      ==a. y = (x < 0)? x:0;==
      B. x = (x < 0)? y:0;
      C. (x < 0)? y = x:y = 0;
      D. y = (x < 0);
      ==e. y = if (x < 0) x:0;==
      Reading books, reading books, reading books, reading books
    1. How many times would the following loop iterate?
      int x = 10;
      do {
      SYSTEM.OUT.PRINTLN (x);
      x--;
      } while (x > 0);
      A. 0 times
      B. 1 times
      C. 9 times
      D. Ten times
      ==e. times==
      There's nothing to say. Do loops are going to do it once, learn math well and count.
    1. Given that's a String, what's does the following loop do?
      for (int j = S.length (); j > 0; j--)
      System.out.print (S.charat (j-1));
      ==a. It prints s out backwards==
      B. It prints s out forwards
      C. It prints s out backwards after skipping, the last character
      D. It prints s out backwards but does not print the 0th character
      E. It yields a run-time error because there is no character at S.charat (j-1) for j = 0
      The variable J counts down from the length of the string to 1, printing out the position j-1 characters at a time. A character of length 1 is the first print character, which is the last character of the string. It continues until it reaches J = 1, and prints out the character at position j-1, or the No. 0 character, so it prints the entire string backwards.
    1. In Java, it's possible to create a infinite loop out of the while and does loops, but not for-loops.
      A. True
      B. False
      Admittedly, while and do loops can be infinite loops, the For loop can be an infinite loop. In many other programming languages, this is not true, the For Loop has a set start and end point, but the Java for loop is much more flexible than for loops in most other languages
Pairing and peer review templates (why reviews me!) )
    • The blog is worth learning or problems

    • Good interface layout
    • The problem analysis is very detailed and has its own thinking
    • The summary of learning is in place, and the issues raised and solved are also very important points of knowledge

    • A worthwhile learning or problem in the code

    • Key code comments Very detailed
    • Based on the scoring criteria, I scored this blog: 14. The score is as follows:
    1. Correct use of markdown syntax (plus 1 points)
    2. Complete features in the template (plus 1 points)
    3. Add 4 points to the problem and solution process in teaching materials learning
    4. Code debugging problems and resolution process, add 4 points
    5. Valid code for this week exceeds 300 branches, plus 2 points
    6. Other bonus points, plus 2 points
    • Beautifully formatted plus one point
    • Add 1 points to the progress bar to record the learning time and improvement situation
This week's study of the knot
    • Student number 21st, pair
    • Pairs of learning content

    • To discuss and study after-school programming project pp8.1 and pp8.5,pp8.6 I'm really not, I hope you learned to save me.

Other (sentiment, thinking, etc., optional)

When I learned to die, Jin said it was simple. I feel so sad, I hope I can beat him to the heart of the ruthless. This week's sentiment is over.

Learning progress Bar
number of lines of code (new product) Blog Volume (new product) Learning Time (new product) Important Growth
Goal 5000 rows 30 Articles 400 hours
First week 200/200 2/2 20/20
Second week 329/500 2/4 18/38
Third week 619/1000 3/7 22/60
Week Four 817/1734 4/7 38/60
Week Five 674/2408 5/7 38/60
Section Liu Zhou 1136/2870 6/7 50/60
Resources
    • JAVA.API online documentation

2017-2018-2 semester 20172324 "Java Program design" Sixth 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.