Java Second day learning content Review--java White Paper Chapter III

Source: Internet
Author: User
Tags shallow copy

  1. For input by the console, you need to use the scanner control to assist, you can use it for an entire row or a single byte of reading, in addition to note that if it is a password input problem, need to take advantage of the console space, its limit can only be fixed to read a whole line at a time.

  2. When Java needs to include some packages, use the import reserved word, unlike the include

  3. Java details on formatted output issues in white paper P57

  4. The use of the String.Format method is similar to print, but differs in that it simply creates a formatted string, while the latter prints out a formatted string.

  5. Multiple print forms for the current time are detailed with the white Paper P59. Use the date () method.

  6. Furthermore, the concept of parameter index values has been found in 5 parts, and the parameter index value starts at 1, because 0 has identifiers that are used as other meanings to prevent confusion, and the parameter index value ends in $

  7. About file write issues, detailed with white paper P60, using the PrintWriter control, when working with files, because you might encounter a situation where the file cannot be found, you need to add throws to the main method after the Filefoundexception Statement tells the compiler that I already know that a file might not be found, and that it contains a package: java.io.*, a read operation on a file needs to take advantage of the scanner control, The Paths.get method enables the file name to be converted to a file pathname, allowing the scanner control to open files instead of creating a string. Note: You will need to use the. Close method to close the file after using open file, otherwise you will not see the write effect.

  8. The current IDE's working directory can be obtained using the System.getproperty ("User.dir") code.

  9. Although Goto has been set as a reserved word in Java, it is actually used in the form of break+ tags or continue+ tags.

  10. The For loop body in Java has a variant form that facilitates the manipulation of each element in an array, which cannot involve subscripts, detailing with white papers P79

  11. The same variable is declared in two blocks in Java that cannot be set in a holster, unlike C + +.

  12. For the comparison of floating-point numbers, it is important to pay attention to the use of floating-point numbers in the loop to compare events that produce an exit loop, which can produce a dead loop.

  13. For switch statements, white Paper authors do not recommend it, but there are some details about the use of p73

  14. Tagged break and tagged continue, respectively, is to jump out of the target loop body and jump into the target loop body, in essence, is to jump out of the target block and jump into the target block, so you can implement multiple nested loops of the jump, the label needs to be set in the loop body (block) before adding:.

  15. For large values, Java provides two classes, BigInteger large integers and bigdecimal large floating-point types, and large numeric operations cannot use operators such as +,-, but instead use the methods provided by the class, because Java does not allow overloaded operators, unlike C + +. Detailed and white paper P77

  16. In Java, there is essentially no multidimensional array but an array of 1-dimensional arrays, and the declaration of an array can take advantage of the variable: int[] a = new int[x];

  17. When you create a numeric array, a Boolean array, an array of objects, all the elements are initialized to 0,false,null;

  18. The array length can be obtained using Array.Length.

  19. For array printing, you can use the Arrays.tostring method, which converts a numeric value into a character formatted output.

  20. In Java, you can use ' = ' to make a shallow copy of the array, the effect of this method is two array shared memory, the deep copy method is the use of arrays.copyof (array, length), for the length parameter can be changed to the size of the target array, the corresponding copy of the resulting value will be truncated or 0, For an array of out-of-bounds access, Java will error.

  21. There is no pointer operation in Java, the elements in the array cannot be obtained by a[] b=a+1, and the Java array is more similar to the C + + comparison with the latter int *name = new int [] instead of int name[100], the essential difference is that one placed in the heap is placed on the stack  , and in the comparison of multidimensional arrays, the former can generate an irregular array, equivalent to the latter's int * * * name = new int[10][]; ++++++ for () name[i]=new Int[i]; This makes the array specifications more flexible and detailed with the white paper P88

  22. The command-line array in Java does not store the program name, unlike the. BinarySearch method, which can find the target value in the array.

  23. The arrays type in Java also provides the. Sort method for sorting, which is an optimized fast-row, and the Math.random method produces 0 to 1 and does not contain 1 random numbers.

This article is from the "Developing_rookie" blog, make sure to keep this source http://8942041.blog.51cto.com/8932041/1627170

Java Second day learning content Review--java White Paper Chapter III

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.