当前位置:网站首页>Day4 operator, self increasing, self decreasing, logical operator, bit operation, binary conversion decimal, ternary operator, package mechanism, document comment
Day4 operator, self increasing, self decreasing, logical operator, bit operation, binary conversion decimal, ternary operator, package mechanism, document comment
2022-07-02 12:50:00 【Onycho】
Operator

Self increasing , Self reduction
package operator;
public class Demo04 {
public static void main(String[] args) {
//++ -- Self increasing , Self reduction Unary operator
int a= 3;
int b = a++; // After executing this line of code , First give b assignment , Since the increase again
// a = a+1
System.out.println(a);
// a = a+1;
int c = ++a; // Before this line of code is executed , First of all, increase by yourself , Give again b assignment
System.out.println(a);
System.out.println(b);
System.out.println(c);
// Power operation 2*3 2*2*2 = 8 Many operations are operated by tool classes !
double pow = Math.pow(2,3);
System.out.println(pow);
}
}
Output
4
5
3
5
8.0
Logical operators
package operator;
// Logical operators
public class Demo05 {
public static void main(String[] args) {
// And (and) or (or) Not ( Take the opposite )
boolean a = true;
boolean b = false;
System.out.println("a && b:"+(a && b)); // Logic and computation : Both variables are true , The result is true
System.out.println("a || b:"+(a||b)); // Logic or operation : One of the two variables is true , The result is true
System.out.println("! (a && b):"+!(a&&b)); // If it is true , It becomes false , If it is false, it becomes true
// Short-circuit operation
int c = 5;
boolean d = (c<4)&&(c++<4);
System.out.println(d);
System.out.println(c);
Output
a && b:false
a || b:true
! (a && b):true
false
5
An operation
package operator;
// An operation
public class Demo06 {
public static void main(String[] args) {
/* A = 0011 1100 B = 0000 1101 A&B = 0000 1100(“ And ” all 1 by 1) A|B = 0011 1101(“ or ” There is one 1 Then for 1) A^C =0011 0001(“ Exclusive or ” Same as 0, Different for 1) ~B = 1111 0010(“ Take the opposite ” The opposite ) 2*8 = 16 2*2*2*2 Very efficient << Move left *2 >> Move right /2, When the arrow points that way, it's called moving 0000 0000 0 0000 0001 1 0000 0010 2 0000 0011 3 0000 0100 4 0000 1000 8 0001 0000 16 */
System.out.println(2<<3);
}
}
Output
16
Binary to decimal
0000 0000 0 Binary default 0
0000 0001 1 From left to right 0~7, be 2^0 = 1
0000 0010 2 2^1 = 2
0000 0011 3 2^1 + 2^0 = 3
0000 0100 4 2^2 = 4
0000 1000 8 2^3 = 8
0001 0000 16 2^4 =16
String connector +
package operator;
public class Demo07 {
public static void main(String[] args) {
int a = 10;
int b = 20;
a += b; //a = a + b
a -= b; //a = a - b
// String connector + , String
System.out.println(a + b);
System.out.println("" + a + b); // String before , The back will be spliced
System.out.println(a + b + ""); // String after , The front can calculate
}
}
Output
30
1020
30
Ternary operator
package operator;
// Ternary operator
public class Demo08 {
public static void main(String[] args) {
// x ? y : z
// If x == true, The result is y, Otherwise z
int score = 80;
String type = score < 60 ?" fail, ":" pass ";
// if
System.out.println(type);
}
}
Output
pass
Packet mechanism

Pay attention to Idea Created in com.baidu When a child package cannot be created automatically
Click the pinion at the top right of the project structure on the left ,
Uncheck the compact middle packlages Options , At this point you build a com.itheima.package package ,
It will be shown as com It's a bag itheima package ,itheima It's a bag package.java!
import com.jiao.*; // Import all classes under this package
Documentation Comments
package com.jiao.base;
/** * @author John * @version 1.0 * @since 1.8 */
public class Doc {
String name;
/** * @param name * @return * @throws Exception */
public String test(String name)throws Exception {
return name;
}
}

doc Order sample
javadoc -encoding UTF-8 -charset UTF-8 Doc.java
边栏推荐
- 深拷貝 事件總線
- Do you know all the interface test interview questions?
- Redis sentinel mechanism and configuration
- Interview with meituan, a 34 year old programmer, was rejected: only those under the age of 30 who work hard and earn little overtime
- Docsify deploy IIS
- 获取文件版权信息
- js 迭代器 生成器 异步代码处理 promise+生成器 -> await/async
- Obtain file copyright information
- JDBC prevent SQL injection problems and solutions [preparedstatement]
- [ybtoj advanced training guidance] judgment overflow [error]
猜你喜欢

Heap acwing 839 Simulated reactor

Five best software architecture patterns that architects must understand

JS10day(api 阶段性完结,正则表达式简介,自定义属性,过滤敏感词案例,注册模块验证案例)

JS8day(滚动事件(scroll家族),offset家族,client家族,轮播图案例(待做))

传感器 ADXL335BCPZ-RL7 3轴 加速度计 符合 RoHS/WEEE
![JDBC prevent SQL injection problems and solutions [preparedstatement]](/img/32/f71f5a31cdf710704267ff100b85d7.png)
JDBC prevent SQL injection problems and solutions [preparedstatement]

The coloring method determines the bipartite graph acwing 860 Chromatic judgement bipartite graph

Interesting interview questions

Js8day (rolling event (scroll family), offset family, client family, carousel map case (to be done))

JS7day(事件对象,事件流,事件捕获和冒泡,阻止事件流动,事件委托,学生信息表案例)
随机推荐
. Net, C # basic knowledge
Js5day (event monitoring, function assignment to variables, callback function, environment object this, select all, invert selection cases, tab column cases)
3 A VTT端接 稳压器 NCP51200MNTXG资料
js1day(輸入輸出語法,數據類型,數據類型轉換,var和let區別)
BOM DOM
Js8day (rolling event (scroll family), offset family, client family, carousel map case (to be done))
What is the relationship between NFT and metauniverse? How to view the market? The future market trend of NFT
Shuttle encapsulated AppBar
绕过ObRegisterCallbacks需要驱动签名方法
Dijkstra AcWing 850. Dijkstra finding the shortest circuit II
NTMFS4C05NT1G N-CH 30V 11.9A MOS管,PDF
Deep copy event bus
3 a VTT terminal regulator ncp51200mntxg data
深拷貝 事件總線
spfa AcWing 852. spfa判断负环
Browser node event loop
[FFH] little bear driver calling process (take calling LED light driver as an example)
Std:: vector batch import fast de duplication method
Interesting interview questions
Interval DP acwing 282 Stone merging