Java modifiers and basic operators

Source: Internet
Author: User
Tags arithmetic arithmetic operators bitwise bitwise operators control characters logical operators modifiers

Java modifiers can be divided into two types

    • Accessible modifiers
    • Non-accessible modifiers

Using modifiers, you can use the definition of the class, method, variable

Accessible modifiers

    • Package visible, default, no modifiers required
    • Can only be visible by class (private)
    • All visible (public)
    • Can only be visible to the current package and all classes (protected)

Non-accessible control characters

    • static modifier for creating class methods and variables Statics
    • Final modifier for completing class, method, and variable implementations final
    • Abstract modifier for creating abstract classes and methods
    • The synchronized and volatile modifiers are used for threading.

Java operators

    • Arithmetic Operators (arithmetic operator)
    • Relational Operators (relational operator)
    • Bitwise Operators (bitwise operator)
    • Logical Operators (logical operator)
    • Assignment Operators (Assignment operator)
    • Misc Operators (Other operators)
算术运算符- +- -- *- /- % (模)- ++- --
关系运算符- == - !=- >- <- <=- >=

Bitwise operators

a = 0011 1100b = 0000 1101a&b = 0000 1100(与,都为1为true)a|b = 0011 1101(或,有1就是true)a^b = 0011 0001(异或,不同就是true)~a  = 1100 0011(取反)a<<2 左移扩大 1111 0000a>>2 右移缩小0000 1111

logical operators

- A && B 都真为真- A||B有真为真- !A 取反

Assignment operators

- =- +=- -=- *=- /=- %=- >>=- &=- ^=- |=

Ternary operators

- varible x =(expression)?value if true:value if false

instanceof

( Object reference variable ) instanceof  (class/interface type)
public class Test {   public static void main(String args[]) {      String name = "James";      // following will return true since name is type of String      boolean result = name instanceof String;      System.out.println( result );   }}

Priority table

Java modifiers and basic operators

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.