0
点赞
收藏
分享

微信扫一扫

【JAVA】注释代码的三种用法!(个人体会,)


1、代码段分隔标题注释,【//】

如://======================= 【标题】

// ======================== 【取最大值函数】

public static int max(int a,int b)
{
int MaxValue=0;
if(a>b)
{
MaxValue=a;
}
else
{
MaxValue=b;
}
return MaxValue;

}

// ======================== 【取最小值函数】

public static int min(int a,int b)
{
int MinValue=0;
if(a>b)
{
MinValue=b;
}
else
{
MinValue=a;
}
return MinValue;

}

2、代码后面加注释【//】

int c=5;
int d=8;
int f=max(c,d); // 这是调用的MAX函数,取最大值。

3、注释整个代码段。【/*    */】

/*

System.out.println("1 --- 大叔");
System.out.println("2 --- 阿姨");
System.out.println("3 --- 小朋友");
System.out.println("4 --- 哥哥");
System.out.print("请选择:");
Scanner in= new Scanner(System.in);

int num=in.nextInt()+1;
String str=":"+num;

System.out.println("您选择的是:"+str);
*/

int c=5;
int d=8;
int f=max(c,d);




举报

相关推荐

0 条评论