声明int型变量a、b、c

内容分享1周前发布
0 0 0

public class Val { //新建类

static int times = 3; //定义成员变量times

public static void main(String[] args) { //主方法

int times = 4; //定义局部变量times

System.out.println(“times的值为:” + times); //将times的值输出

}

}

public class Eval { // 创建类

public static void main(String[] args) { // 主方法

int a, b, c; // 声明int型变量a、b、c

a = 15; // 将15赋值给变量a

c = b = a + 4; // 将a与4的和赋值给变量b,然后再赋值给变量c

System.out.println(“c值为:” + c); // 将变量c的值输出

System.out.println(“b值为:” + b); // 将变量b的值输出

}

}

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
none
暂无评论...