class VarDemo
{
public static void main(String[] args)
{
//数据类型 变量名 = 初始化值;
byte b = 3;
short s = 4000;
int x = 12;
long l = 123l;
float f = 2.3f;
double d = 3.4;
char ch = '1';
boolean bl = true;
bl = false;
{
int z = 9;
System.out.println(z);
}
//System.out.println(z); // 注意变量的使用范围
//System.out.println(y); // 此处变量没有定义
}
}
{
public static void main(String[] args)
{
//数据类型 变量名 = 初始化值;
byte b = 3;
short s = 4000;
int x = 12;
long l = 123l;
float f = 2.3f;
double d = 3.4;
char ch = '1';
boolean bl = true;
bl = false;
{
int z = 9;
System.out.println(z);
}
//System.out.println(z); // 注意变量的使用范围
//System.out.println(y); // 此处变量没有定义
}
}
本文提供了一个Java程序示例,展示了如何使用各种基本数据类型,包括整型、浮点型、字符型和布尔型,并通过一个简单的程序演示了这些类型的使用方法。
776

被折叠的 条评论
为什么被折叠?



