当前位置:网站首页>Process control and method
Process control and method
2022-06-25 16:19:00 【weixin_ forty-eight million six hundred and forty-four thousand】
- Assignment operator
public class _01 {
public static void main(String[] arys){
byte i=2;
i+=3;
i++;
System.out.println(i);
int a=10;
a*=a+=1;
a*=a+=1;
System.out.println(a);
}- String mosaics
public class _02 { public static void main(String[] args){ String string=" Give the green light to the plane i whether "; int a = 100; int b = 120; System.out .println(a+b); System.out .println("a+b="+a+b); System.out .println(a+"+"+b+"="+(a+b)); }
- Ternary operator
- Process control
Different branches of the control program
- Sequential structure
Strictly from top to bottom , From left to right
- Branching structure
Through the specified judgment conditions , Selectively take different branches
- if...else...
public class _04 { public static void main(String[] args){ int a= 100; int b=11; if(a>10){ System.out.println("1111"); } else if(a>50){ System.out.println("2222"); }else if (a>100){ System.out.println("3333"); } if(true) System.out.println(" Execution completed "); else System.out.println(" Execution completed "); }public static void main(String[] args){
Scanner scanner =new Scanner(System.in);
System.out.println(" Please enter a user name , And press enter to confirm ");
String username=scanner.next();
System.out.println(" Please input a password , And press enter to confirm ");
String password=scanner.next();
if(username.equals("admin")){
if(password.equals("root")){
System.out.println(" Landing successful ");
}else{
System.out.println(" Incorrect password ");
}
}else
System.out.println(" Incorrect user name , To register ");
}
- Switch
public class _08 {
public static void main(String[] args) {
char c = 'C';
if (c == 'A' || c == 'B') {
System.out.println(" good ");
} else if (c == 'C') {
System.out.println(" good ");
}
switch (c) {
case 'A':
case 'B':
System.out.println(" good ");
break;
case 'C':
System.out.println(" good ");
break;
}
}
- Loop structure
Repeat some code many times
- For
- Single cycle
public class _10 {public static void main(String[] args) { for (int i = 0; i < 5; i++) { System.out.println(i); } int i; for ( i =0 ; i < args.length; i++) { System.out.println(i); } System.out.println(i); }
- For
- Nested loop
public class _11 { public static void main(String[] args) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { System.out.print(0+" "); } System.out.println(); } }
- While
public static void main(String[] args){ int i=10; while(i<100){ System.out.println(i); i++; } }
- Do...while
public static void main(String[] args){ int i=1000; do{ System.out.println(i); i++; }while(i<100); }
- Break&continue
public static void main(String[] args) { for (int i = 0; i < 10; i++) { if (i == 3) { break; } System.out.println(i); } }public static void main(String[] args) { for (int i = 0; i < 10; i++) { if (i == 3) { break; } System.out.println(i); } }public static void main(String[] args) { outerFor: for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (j == 3) { break outerFor; } System.out.print(j + " "); } System.out.println(); } }
- Method
- summary
- Method statement
* Statement :
* List of modifiers return type Method name ( parameter list ){ Method body }
*
* List of modifiers : There can be , There can be no , There can be multiple
* Authority modification : public protected private Don't write One out of four
* Other modifications : static , synchronized
abstract , final A choice .....
return type : 11 Any of several data types , If no return value is required , Then write void
Method name : The name of the method , Look at the text and know the meaning , Hump nomenclature
parameter list : One thing to do , Required prerequisites , Can be used as input parameter
There can be multiple , use , commas such as int a , int b , int c....
Shape parameter : At the time of method declaration , Defined parameter list
Actual parameters : Method call , Actual incoming data
Method body : Code to execute
Be careful : return Terminate the method and return
If there is a method with return value type , The method body must have return sentence
such as public static int m1(){
return 1;// there 1 As long as it is int value , Because the return value is int type
}
If no return value Then you can write return Or not , Write it return Also cannot return data , Can only terminate the operation
public static void m1(){
return; // Only the function of terminating method operation
}
- Methods classification
public static void main(String[] args) { int result =_19.m1(123,5312); System.out.println(result); } public static int m1(int a , int b){ return a+b; } public static void m2(){ return ; }
边栏推荐
- 读配置、讲原理、看面试真题,我只能帮你到这了。。。
- 合宙Air32F103CBT6開發板上手報告
- Most commonly used SQL statements
- Built in function globals() locals()
- Classic deadlock scenario of multithreading and its solution (philosopher dining problem)
- 什么是NFT数字藏品?
- Webgl and webgpu comparison [4] - uniform
- f_ Read function [easy to understand]
- Yadali brick playing game based on deep Q-learning
- What plug-ins are available for vscade?
猜你喜欢

Overall MySQL architecture and statement execution process

不要小看了积分商城,它的作用可以很大!
Classic deadlock scenario of multithreading and its solution (philosopher dining problem)

Alvaria宣布客户体验行业资深人士Jeff Cotten担任新首席执行官

Rxjs TakeUntil 操作符的学习笔记

Interviewer: your resume says you are proficient in mysql, so you say cluster / Union / overlay index, table return, index push down

Alvaria announces Jeff cotten, a veteran of the customer experience industry, as its new CEO
Mixed density network (MDN) for multiple regression explanation and code example

商城风格也可以很多变,DIY 了解一下!
Power representation in go language
随机推荐
李飞飞团队将ViT用在机器人身上,规划推理最高提速512倍,还cue了何恺明的MAE
Tensorflow loading cifar10 dataset
The paid video at station B caused the up master to lose more than ten thousand fans
Based on neural tag search, the multilingual abstracts of zero samples of Chinese Academy of Sciences and Microsoft Asiatic research were selected into ACL 2022
不要小看了积分商城,它的作用可以很大!
AutoK3s v0.5.0 发布 延续简约和友好
GridLayout evenly allocate space
Prototype mode
Blue Bridge Cup - practice system login
Multiple decorators decorate a function
Share the code technology points and software usage of socket multi client communication
Rapport de la main - d'oeuvre du Conseil de développement de l'aecg air32f103cbt6
绕过技术聊'跨端'......
[Third Party framework] retrofit2 (2) - add point configuration of network access framework
What are some tricks that novice programmers don't know?
深度学习 pytorch cifar10数据集训练「建议收藏」
合宙Air32F103CBT6開發板上手報告
Geographic location data storage scheme - redis Geo
Problems caused by using ApplicationContext to render layout
原生js动态添加元素