java-basic-3-operator-modifier-loop

Source: Internet
Author: User

Operator:

Similar to C + +, Special:

1) Bitwise right SHIFT 0 Operator:

2) instanceof Operator: Determine if an instance is a class/interface type

Returns true if the/type is compatible

Superclassclass Vehicle {}//Subclassclass Car extends Vehicle {}public class test{public static void Main (String args[  ] {Vehicle a = new Car ();//Return TrueSystem.out.println (a instanceof Car);//Return TrueSystem.out.println (a instanceof Vehicle);}}

Modifier:

1) Access Control modifiers

    • Default

is visible to the class within the same package.

In the interface: The variable is public static final, the method is public.

    • Private

Classes and interfaces cannot be declared as private.

    • Public

All public methods and variables of a class can be inherited by its subclasses.

    • Protected

Variables, methods, and constructors declared as protected can be accessed by any other class in the same package, or by subclasses in different packages .

The member variables and member methods of an interface cannot be declared as protected

@@@@@@@@@

   

@@@@@@@@@

2) non-access modifiers

    • Static
      • Static methods cannot use non-static variables of a class.
    • Final
      • The reference to the final object cannot be changed, but the value inside can be changed.
      • Typically used with the static modifier to create class constants
      • The final method in the class can inherit from the quilt class, but cannot be modified by the quilt class.
      • Final class cannot be inherited
    • Abstract
      • If a class contains several abstract methods, the class must be declared as an abstract class.
      • Abstract classes can contain no abstract methods.
    • Synchronized
      • Declared methods can only be accessed by one thread at a time. The synchronized modifier can be applied to four access modifiers.
      • Public synchronized void ShowDetails () {}
    • transient modifier
    • volatile modifier
public class Test{public static void Main (string args[]) {string str[] = {"A", "B", "PXY"};//variable ' s type = array ' s Ty Pefor (String word:str) {System.out.print (word + "*");}}}

java-basic-3-operator-modifier-loop

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.