What is the 1 operator?
Operators that operate on constants and variables
What are the 2 operators divided into
Arithmetic operators (+,-, *,/),
Assignment operators
Comparison operators
logical operators
Bitwise operators
Trinocular operator
3 operator
Considerations for a arithmetic operator
(1) Integer division can only be integers, if you want a decimal, you must change the data to a floating-point number type
(2)/Gets the quotient of the division operation,% gets the remainder of the division operation
Code detection
classOperatordemo { Public Static voidMain (string[] args) {//Defining Variables intx = 3;//assign 3 to variable x of type int inty = 4; SYSTEM.OUT.PRINTLN (x+y); SYSTEM.OUT.PRINTLN (x-y); SYSTEM.OUT.PRINTLN (x*y); SYSTEM.OUT.PRINTLN (x/y);//dividing integers can only get integers//I want to get a decimal, the swelling? //simply change any of the data in the operation to a floating-point numberSystem.out.println (x*1.0/y); //% of ApplicationsSystem.out.println (x%y);//the remainder is obtained. }}
Use of the,--operator for B + +:
Used alone:
Put in front of the operand and follow the same effect. (This usage is more common to us)
Participate in the operation using:
Put in front of the operand, increment or decrement first, and then participate in the operation.
After the operand, it participates in the operation, then increases or is self-reduced.
Function: The variable is self-increment 1 or self-minus 1.
Practice Topics
1 classOperatortest {2 Public Static voidMain (string[] args) {3 intA = 10;4 intb = 10;5 intc = 10;6 7A = b++;//a=10,b=11,c=108c =--a;//a=9,b=11,c=99b = ++a;//a=10,b=10,c=9TenA = c--;//a=9,b=10,c=8 One ASystem.out.println ("A:" +a); -System.out.println ("B:" +b); -System.out.println ("C:" +c); theSystem.out.println ("--------------"); - - intx = 4; - inty = (x + +) + (++x) + (x*10); + //4+6+60 - //x=5,6 + ASystem.out.println ("x:" +x); atSystem.out.println ("Y:" +y); - } -}
Use of C +:
A: Addition
B: plus sign
C: String connector
1 classOperatorDemo3 {2 Public Static voidMain (string[] args) {3 //addition4System.out.println (3+4);5 6 // Plus7System.out.println (+4);8 9System.out.println (' a ');TenSystem.out.println (' a ' + 1);//Here's the addition . One A //String Connector -System.out.println ("Hello" + ' a ' +1); -System.out.println (' A ' +1+ "Hello"); the } -}
Arithmetic operators for Java Note 2