Java Note 3

Source: Internet
Author: User

  1. A class that allows each information to be designed and implemented only once, and then reused without having to re-analyze and adjust the representation of the information.

  2. Window settings

    Import javax.swing.*;

    JFrame W1 = new JFrame ("bigger");

    W1.setsize (200, 125);

    W1.setvisible (TRUE);

  3. Color, rectangle settings in a class

    Import java.awt.*; AWT is the earliest Java graphics library

    Import javax.swing.*;

    private color color;

    Private JFrame window;

    window = new JFrame ("box fun");

    color = Color.Blue;

    Graphics g = window.getgraphics ();

    G.setcolor (color);

    G.fillrect (x, y, width, height);


  4. In Java, the properties of an object are usually referenced as data fields, and a variable is used to represent the data field, which is called an instance variable .

  5. The default initial value of a numeric instance variable is 0, the default initial value of a Boolean instance variable is False, and the default initial value of the reference instance variable is null.

  6. Private, the modifier states that direct access to the corresponding instance variable is limited to the class itself. That is, you can access these instance variables only through the methods of that class.

  7. Construction Method , is a special Java method. When you use the construct method, Java automatically creates new objects that have all the familiarity of the class. the work of the construction method is to explicitly specify values for those attributes. The default construction method configures a new instance of the class without any external import, with no return type, and the method name is the same as the class name.

  8. An instance method, also called a member method. Common methods in the class. Different invocations can associate an instance method with a different object. The method signature is: Method name (parameter list)

Java Note 3

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.