Java Note 1

Source: Internet
Author: User

  1. Java requires that the public class name be the same as the program file name.

  2. Identifier in Java: preceded by a letter, underscore ' _ ' or dollar sign ' $ '; the other characters in the identifier must be letters, numbers, underscores, or $; identifiers cannot have spaces; identifiers cannot exceed 65,535 characters in length. The characters here are characters in the Unicode character set.

  3. The public modifier indicates that this method can be used by other Java classes, which can be defined in the same file or in different files;

  4. The static modifier description Method Main () is a service provided by the class and does not need to be associated with a specific class object. Such a method is called a class method.

  5. The System.out is the standard output stream.

  6. The text string in the program is not allowed to occupy more than a row. The following statements are illegal:

    System.out.print ("Sdfasgsd

    SDFASGFGFDG ");

  7. Constants must be defined and initialized before constants are used in calculations. The keyword final is used to modify constants.

  8. The use of System.out.print.

    int num=10;

    System.out.print ("Hello" +num);

  9. Math.Round () is a class method of the Java.lang.Math standard class. The parameter is a floating-point number of type double that returns the nearest integer value.

  10. Simple types of Java: Byte, short, int, long, char, double, float, Boolean.

  11. Byte byte, short two bytes, int four bytes, long eight bytes, char one byte, float four bytes, double eight bytes, Boolean one. The float variable usually has only 6 valid digits, and the double value has 15 valid digits.

  12. Lowercase converted to corresponding uppercase: Char lower= ' C '; Char upper= ' A ' +lower-' a ';

  13. Java's Java.lang.Character provides a class method:

    Char character.tolowercase (char ch) output corresponding lowercase letter

    Char character.touppercase (char ch) output corresponding uppercase letters

  14. Java defines constants in advance, which are members of Integer, double, and float, which are part of the standard package Java.lang.

    Integer.max_value int Type the largest positive integer value

    Integer.min_value the smallest positive integer value of type int

    Double.max_value maximum positive value of type double

    Double.min_value the smallest positive value of the double type

    Double.positive_infinity double type positive infinite large value

    Double.negative_infinity double type negative infinite large value

    Double.NaN the value of the non-numeric type of the double type, which does not correspond to any number

  15. System.out.print (1+2+ "3");

    System.out.print ("1" +2+3);

    Output:

    33

    123

  16. Import java.io.*;


Java Note 1

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.