Multiple cycles, methods and operations

< p align = "center" > multiple loops and methods

1、 Multiple choice questions

eight

String

}

ninety-nine

private String example(){…}

2、 Judgment question

3、 Short answer

(1) normally, break just jumps out of the inner loop.

(2) you can use the labeled break, which is equivalent to goto. For example, break a refers to exiting the loop where a is located. However, this method is not recommended because it can't get out if there are too many jumps

In addition, the use of continue with label is similar

Examples

                 i=0 
                 j=0  a: (;i<10;i++  b:(;j<10;j++  (j==4   a;      

Definition: if a class contains more than two methods with the same name, they constitute overload characteristics: 1. There must be more than two methods with the same name. 2 Parameter combinations must be different between methods (the number of parameters is different or the type of parameters is different) 3. The return value of the method cannot be used as the basis for judging whether overloads are formed between methods. The advantage is that the code of the class caller is greatly simplified, which makes us feel that the class has a function of automatic call without adding the code of class creation

4、 Coding question

  2. Judge how many primes are between 1-100 and output all primes. (extract the function of judging whether a number is a prime number into a method and call it directly in the loop)

  3. Input the scores of 10 students in three classes, sum and average

5、 Topic selection

  2. Definition method: prints the rectangle of the specified row and column

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>