Keywords in Java

Source: Internet
Author: User
Tags modifier

Access control private    protected    public   ellipsis class, method and variable modifier abstract    class    extends    final    implements    interface    native    newstatic    strictfp    synchronized    transient    volatile    Program control break    continue return does while if-else for    instanceof    Switchcase    default    exception handling try    cathc    throw    throws packet related import    package    Basic Type Boolean    byte    char    double    float    int    long    short    null    true    False variable reference Super    this    void    reserved word goto    Const    

These classes, methods, or fields can only be referenced in a class that declares private (inner) classes, methods, or fields. They are not visible outside of the class or for subclasses.
The default access scope for all class members is package access, which means that class members can be accessed from any class in the same packet, unless there is a specific access control modifier.
2) The protected protected protected keyword is an access control modifier that can be applied to a class, method, or field (a variable declared in a class). You can declare a class, a method, or a field in a protected class,

Package access, that is, you can access class members from any class in the same packet unless there is a specific access control modifier.
3) Public
The Public keyword is an access control modifier that can be applied to a class, method, or field (a variable declared in a class). The public class, method, or field may only be referenced in any other class or package. The default access scope for all class members is package access, which means that class members can be accessed from any class in the same packet, unless there is a specific access control modifier. 1) Abstract Declaration abstraction
The abstract keyword can modify a class or method. The abstract class can be extended (adding subclasses), but not directly instantiated. The abstract method is not implemented in the class in which it is declared, but must be overridden in a subclass. Classes that use the abstract method are inherently abstract classes and must be declared abstractly. 2) class
The class  keyword is used to declare a new  Java  class, which is a collection of related variables and/or methods. Class is the basic construction unit of object-oriented program design method. A class typically represents some kind of actual entity, such as a geometry or a person. A class is a template for an object. Each object is an instance of the class. To use a class, you typically use the  new  operator to instantiate an object of the class, and then invoke the class's methods to access the functionality of the class.  3) extends inherited, extended extends keywords are used in class or interface declarations to indicate that the class or interface being declared is a subclass of the class or interface with the extends keyword followed by its name. Subclasses inherit all public and protected variables and methods of the parent class. Subclasses can override any non-final method of the parent class. A class can only extend one other class.  4 final, immutable final keyword can be applied to a class to indicate that the class cannot be extended (no subclasses). The final keyword can be applied to a method to indicate that this method cannot be overridden in a subclass. A class cannot be both abstract and final. Abstract means that the class must be extended, and final means that the class cannot be extended. A method cannot be both abstract and final. Abstract means that the method must be overridden, and final means that the method cannot be overridden.  5) New, create a new keyword to create a fresh instance of the class. The argument after the new keyword must be a class name, and the class name must be followed by a set of constructor method parameters (which must be enclosed in parentheses). The parameter collection must match the signature of the constructor method of the class. = The type of the variable on the left must have an assignment compatibility relationship with the class or interface to be instantiated.  6) static statics keyword can be applied to an inner class (a class defined in another Class), a method, or a field (a member variable of a class). Typically, the static keyword means that the entity to which it is applied is available outside any specific instance of the class that declares the entity. A static (inner) class can be instantiated and referenced by other classes, even if it is a top-level class. In the example above, the code in another class can instantiate the Mystaticclass class by qualifying its name with the class name that contains it, such as Myclass.mystaticclass. The static field (the member variable of the class) exists only once in all instances of the class. You can call the static method from outside the class without first instantiating the class. Such a reference always includes the class masterpiece as the qualifier for the method call.

Keywords in Java

Related Article

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.