当前位置:网站首页>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
边栏推荐
- C modifier
- 1380. Lucky numbers in the matrix [two-dimensional array, matrix]
- Do you know all the interface test interview questions?
- Anxiety of a 211 programmer: working for 3 years with a monthly salary of less than 30000, worried about being replaced by fresh students
- js5day(事件监听,函数赋值给变量,回调函数,环境对象this,全选反选案例,tab栏案例)
- 深拷贝 事件总线
- JDBC 预防sql注入问题与解决方法[PreparedStatement]
- JS10day(api 阶段性完结,正则表达式简介,自定义属性,过滤敏感词案例,注册模块验证案例)
- FBX import under ue4/ue5 runtime
- Input box assembly of the shutter package
猜你喜欢

Js7day (event object, event flow, event capture and bubble, prevent event flow, event delegation, student information table cases)

Heap acwing 838 Heap sort

3 a VTT terminal regulator ncp51200mntxg data

BOM DOM

Lekao.com: experience sharing of junior economists and previous candidates in customs clearance
![1380. Lucky numbers in the matrix [two-dimensional array, matrix]](/img/8c/c050af5672268bc7e0df3250f7ff1d.jpg)
1380. Lucky numbers in the matrix [two-dimensional array, matrix]

深拷貝 事件總線

Dijkstra AcWing 850. Dijkstra求最短路 II

Js6day (search, add and delete DOM nodes. Instantiation time, timestamp, timestamp cases, redrawing and reflow)

In development, why do you find someone who is paid more than you but doesn't write any code?
随机推荐
Js5day (event monitoring, function assignment to variables, callback function, environment object this, select all, invert selection cases, tab column cases)
绕过ObRegisterCallbacks需要驱动签名方法
浏览器存储方案
Redis introduction, scenario and data type
Lekao: 22 year first-class fire engineer "technical practice" knowledge points
Wechat official account payment prompt MCH_ ID parameter format error
深拷贝 事件总线
[FFH] little bear driver calling process (take calling LED light driver as an example)
深拷貝 事件總線
Js8day (rolling event (scroll family), offset family, client family, carousel map case (to be done))
Interesting interview questions
Use MySQL events to regularly perform post seven world line tasks
About asp Net MVC project in local vs running response time is too long to access, the solution!
软件测试面试题-2022年大厂面试题合集
Enhance network security of kubernetes with cilium
PR 2021 quick start tutorial, learn about the and functions of the timeline panel
面渣逆袭:MySQL六十六问,两万字+五十图详解!有点六
Obtain file copyright information
Js1day (syntaxe d'entrée / sortie, type de données, conversion de type de données, Var et let différenciés)
std::vector批量导入快速去重方法