• Java 语言基础


    1.关键字

    Java关键字是电脑语言里事先定义的,有特别意义的标识符,有时又叫保留字,还有特别意义的变量。Java的关键字对Java的编译器有特殊的意义,他们用来表示一种数据类型,或者表示程序的结构等

    2.标识符

    3.注释

    //解释程序的文字

    /**/

    4.常量和变量

    常量表示不能改变的数值

    5.运算符

    6.语句


    public class Yuju {
    public static void main(String[] args)
    {
    /*for(int x=0; x<5; x++)
    {
    for(int y=x; y<5; y++)
    {
    System.out.print("*");
    }
    System.out.println();
    }*/
    /*for(int x=1; x<=9 ; x++)
    {
    for(int y=1; y<=x; y++)
    {
    System.out.print(y+"*"+x+"="+x*y+" ");
    }
    System.out.println();
    }99乘法表*/
    for(int i=1; i<=5; i++)
    {
    for(int j=1; j<=i; j++)
    {
    System.out.print(" ");

    }
    for(int a=i; a<=5; a++)
    {
    System.out.print("* ");
    }
    System.out.println();
    }
    }

    }

    7.函数


    public class Hanshu {
    public static void main(String[] args)
    {
    draw(4,6);
    draw(7,9);
    }
    public static void draw(int row,int col)
    {
    for(int x=1;x<=row;x++)
    {
    for(int y=1;y<=col;y++)
    {
    System.out.print("*");
    }
    System.out.println();
    }
    }
    public static boolean equals(int a,int b)
    {
    return a==b;//比较ab是否相等
    }
    public static int getMax(int a,int b)
    {
    return a>b?a:b;//返回ab中较大者
    }
    public static char getlevel(int num)
    {
    char level ;
    if(num>=90 && num<=100)
    level = 'A';
    else if(num>=80 && num<=89)
    level = 'B';
    else if(num>=70 && num<=79)
    level = 'C';
    else if(num>=60 && num<=69)
    level = 'D';
    else level = 'E';

    return level;

    }

    }

    8.数组

  • 相关阅读:
    ubuntu十年
    国内开源镜像站
    vi 配置文件
    如何查看Linux命令源代码
    gedit乱码问题的解决
    Linux启动项修复
    我写新年愿望
    SEGGER J-Link 弹窗 在altium designer中禁用USBJATG
    线缆测试,手机端程序说明
    养兔场 网站上的个人介绍
  • 原文地址:https://www.cnblogs.com/myywsy/p/8057389.html
Copyright © 2020-2023  润新知