当前位置:网站首页>Day08 ternary operator extension operator character connector symbol priority
Day08 ternary operator extension operator character connector symbol priority
2022-07-05 07:36:00 【33 year old Java enthusiast】
Ternary operator ( Conditional operator )
x ? y : z ( Because there are three factors , Commonly known as ternary )
If x ==turn , The result is y, Otherwise z
Conditions ?turn Output :false Output ( amount to if sentence )
package operator;
public class demo06Day07 {
public static void main(String[] args) {
int a = 59;
//boolean b=true;
String c= a>60?" pass ":" fail, "; // If a Greater than 60, Then output the first value , Otherwise, output the second value .
System.out.println(c);
}
}
Extended assignment operators
- +=
- -+
- *=
- /=
package operator;
public class demo05Day07 {
public static void main(String[] args) {
int a =10;
int b =20;
a+=b;// a = a+b
System.out.println(a);
//a-=b;// a= a-b
//System.out.println(a);
//a*=b;// a= a*b
//System.out.println(a);
//a/=b;// a= a/b
//System.out.println(a);
}
}
String connector
package operator;
public class demo07Day07 {
public static void main(String[] args) {
int a=10;
int b = 20;
System.out.println(" The output is :"+a+b);// First recognize the string , Connect according to string rules
System.out.println(" The output is :"+(a+b));// Recognize parentheses , The parentheses are finished , Then connect in sequence
System.out.println(a+b+" The output is :");// After the operation, it is connected with the string
/* If the string is recognized first in order , Just connect by string without operation */
}
}
Symbol priority , Be careful
- If you identify the string first , Is to string all the strings
- If the operation is recognized first , Just calculate first and then string .
summary : It depends on which priority , I'll do that .
priority :
- () Parentheses operate first
- /
- According to the order
边栏推荐
- 【idea】Could not autowire. No beans of xxx type found
- How to deal with excessive memory occupation of idea and Google browser
- CADD课程学习(6)-- 获得已有的虚拟化合物库(Drugbank、ZINC)
- Basic series of SHEL script (II) syntax + operation + judgment
- Idea to view the source code of jar package and some shortcut keys (necessary for reading the source code)
- Using GEE plug-in in QGIS
- Butterfly theme beautification - Page frosted glass effect
- Numpy——1.數組的創建
- Matrix and TMB package version issues in R
- 氢氧化钠是什么?
猜你喜欢

Ue5 hot update - remote server automatic download and version detection (simplehotupdate)

Oracle-触发器和程序包

Miracast技术详解(一):Wi-Fi Display

What is deep learning?

HDU1231 最大连续子序列(分治or动规or双指针)

Tshydro tool

行测--资料分析--fb--高照老师

(tool use) how to make the system automatically match and associate to database fields by importing MySQL from idea and writing SQL statements

并查集理论讲解和代码实现

Machine learning Seaborn visualization
随机推荐
UNIX commands often used in work
Light up the running light, rough notes for beginners (1)
Hdu1232 unimpeded project (and collection)
Daily Practice:Codeforces Round #794 (Div. 2)(A~D)
Idea to view the source code of jar package and some shortcut keys (necessary for reading the source code)
Idea shortcut key
CADD course learning (6) -- obtain the existing virtual compound library (drugbank, zinc)
msys2
Basic series of SHEL script (II) syntax + operation + judgment
Set theory of Discrete Mathematics (I)
QT small case "addition calculator"
"Source code interpretation" famous programmer TJ's only library
Differences between pycharm and idle and process -- join() in vs Code
Line test -- data analysis -- FB -- teacher Gao Zhao
氢氧化钠是什么?
使用go语言读取txt文件写入excel中
Chapter 2: try to implement a simple bean container
Typescript get timestamp
[MySQL] database knowledge record
数字孪生实际应用案例-风机篇