快去自定义签名吧~|

园龄:粉丝:关注:

Java基础篇

Java 流程控制

基础篇

Scanner

break

continue

Scanner

next()

nextLine()

hasnext() 下一个对象 用于if

hasnextLine()

System.in 输入

System.out 输出

Scanner scanner=new Scanner(System.in);
new Scanner(System.in) alt+enter
scanner.close(); IO流 输入输出流
if(scanner.hasnextLine)
new Scanner(system.in) ale+enter
while(scanner.hasNextDouble()){
double x = scanner.nextDouble();
m=m+1;
sum=sum+x;
}
sout 巴拉巴拉
scanner.close();
switch(nice){
case value:
break;
case value:
break;
default:
}
反编译---项目结构
Project Structure--Project---文件路径
复制到当前文件夹
while
do...while
for
while(){
}
do{
}while();
for(int i=0;i<=100;i++){}
100.for 回车
int oddSum=0;
int evenSum=0;
100.for
if(i%2!=0){}
System.out.print() 不换行
System.out.printIn() 换行
"\t" Tab空格
"\n" 换行

九九乘法表

public static void main(String[] args) {
CC1();
/*
1
12
123
*/
System.out.println();
CC2();
/*
123
12
1
*/
}
public static String CC1(){
for(int i=1;i<=9;i++){
for(int j=1;j<=i;j++){
System.out.print(j+" * "+i+" = "+i*j +"\t");
}
System.out.println();
}
return null;
}
public static String CC2(){
for(int i=9;i>0;i--){
for(int j=1;j<=i;j++){
System.out.print(j+" * "+i+" = "+i*j +"\t");
}
System.out.println();
}
return null;
}

增强for循环

int[] numbers ={10,20,30,40,50};
for(int x:numbers){
sout (x)
}

break 终止循环

continue 终止某次循环

label:标签
goto
outer 跳转
outer:for(巴拉巴拉)
if(巴拉巴拉)
continue outer;

打印三角形

public static void main(String[] args) {
for (int i = 5; i > 0; i--) {
for(int x=i;x>0;x--){
System.out.print(" ");
}
for (int y=i;y<6;y++){
System.out.print("*");
}
for (int z=i+1;z<6;z++){
System.out.print("*");
}
System.out.println();
}
}

本文作者:youget

本文链接:https://www.cnblogs.com/youget/p/17306678.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   有搞头  阅读(8)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
   
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起