java中的变量
public class learn { //类名必须和文件名保持一致。
public static void main(String[] args){
System.out.println("This is my first Java programe.");
System.out.println("This is a programe.");
}
}
静态变量申明与使用
public class learn{
static final double PI=3.1415926;
static int age = 20;
public static void main(String[] args){
final int number;
number = 1235;
age = 22;
System.out.println(number);
System.out.println(age);
System.out.println(PI);
}
}
public class learn{
static int times = 3;
static int y=90;
public static void main(String[] args){
int times = 4;
System.out.println(times); // 局部变量在方法中有效
System.out.println(exam001.y); //静态变量调用
}
}
public class learn{
public static void main(String[] args){
int a,b,c;
a = 15;
c=b=a+4; //在Java中可以把赋值运算符连在一起使用,但实际开发中不建议这样写。
System.out.println(a);
System.out.println(c);
System.out.println(b);
}
}
- 点赞
- 收藏
- 关注作者
评论(0)