Java Trivia points

Source: Internet
Author: User

by forcing the type conversion to assign 75.8 to the int variable, the result is 75, and the number is not rounded, but the decimal bit is truncated directly


>, <, >=, <= only support the left and right operands are numeric type = =, the operands on both sides can be numeric types, or reference types

Modulo operation% 30%4=2 30 inside each take out 4 last left 2

Switch the value of the expression after the parentheses must be an integer or character type case after the value can be a constant value, such as 1, 2, or it can be a constant expression, such as a, but not a variable or an expression with a variable, such as a * 2 case match, execute the code in the matching block, if not met Break continues to execute the contents of the next case block until the break statement is encountered or the switch statement block ends

While it is first judged and executed again, it is executed once again until the condition is not met and guaranteed to be executed at least once.

Break jumps out of the loop after break the statement is no longer executed but executes the circular field statement continue the effect is to skip the remaining statements in the loop body to perform the next loop.
int Score[]=new int[]{2,3,4,5}; You cannot specify an array length score.length the length of an array when assigning values at the same time

Java.util.Arrays; Arrays.sort (scores) ascending arrays.tostring (scores) converts an array to a string

Int[] Scores = {89, 72, 64, 58, 93}; Arrays.sort (scores);//Use foreach to iterate through the elements in the output array for (int score:scores) {//type variable SYSTEM.OUT.PRINTLN (score);}
int num= (int) (Math.random () *100), random number
by outputting The result, we can see that the static initialization block is executed first when the program is run, then the normal initialization block is executed, and the construction method is finally executed. Because static initialization blocks are only executed once when the class is loaded, static initialization blocks are not executed when the object Hello2 is created again.
Packages in Java: Managing Java files Resolving file conflicts with the same name all lowercase letters

From for notes (Wiz)

Java Trivia points

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.