| 数据类型 | 存储大小 | 举例 | 注释 | 包装类 |
|---|---|---|---|---|
| byte | 1byte | 3 | 字节 | Byte |
| int | 4byte | 4 | 整数 | Integer |
| short | 2bytes | 5 | 短整数 | Short |
| long | 8bytes | 6 | 长整数 | Long |
| float | 4bytes | 1.3 | 单精度浮点型 | Float |
| double | 8bytes | 1.2 | 双精度浮点型 | Double |
| char | 2bytes | ‘a' | 字符 | Char |
| boolean | 1bit | true | 布尔值 | Boolean |
public class Test {
public static void main(String[] args){
System.out.println("8种基本数据类型");
int a=5;
System.out.println(a);
char b='z';
System.out.println(b);
boolean d=false;
System.out.println(d);
byte e=3;
System.out.println(e);
short f=4;
System.out.println(f);
long g=32000000;
System.out.println(g);
float h=5;
System.out.println(h);
double i=6;
System.out.println(i);
}
}
8种基本数据类型 5 z false 3 4 32000000 5.0 6.0
int a=1;
Employee a=new Emploee(1.4);
public class Wrapper {
static class Employee{
static int age;
Employee(int a){
age=a;
}
}
static class Employer{
static int year;
Employer (int y){
year=y;
}
@Override
public String toString() {
return "Employer's year="+year;
}
}
public static void main(String[] args){
Employee e=new Employee(4);
System.out.println("e="+e);
Employer f=new Employer(5);
System.out.println("f="+f);
}
}
e=Wrapper$Employee@1b6d3586 f=Employer's year=5
private final double value;
public String toString() {
return toString(value);
}
byte a=128;
public class TestOne {
public static void main(String[] args) {
int a=127;
System.out.println(a);
int[] b=new int[]{1,2,3};
System.out.println(b);
int[] c=new int[100];
System.out.println(c);
int[] d={1,2,3};
System.out.println(d);
boolean e=false;
System.out.println(e);
boolean[] f={false,false,true};
System.out.println(f);
char g='a';
System.out.println(g);
char[] h={'a','b','c'};
System.out.println(h);
char[] i=new char[]{'a','b','c'};
System.out.println(i);
float j=1.2f;
System.out.println(j);
float[] k={1.2f,1.3f,1.4f};
System.out.println(k);
}
}
127 [I@15db9742 [I@6d06d69c [I@7852e922 false [Z@4e25154f a abc abc 1.2 [F@70dea4e
public void print(char c) {
write(String.valueOf(c));
}
private void write(String s) {
try {
synchronized (this) {
ensureOpen();
textOut.write(s);
textOut.flushBuffer();
charOut.flushBuffer();
if (autoFlush && (s.indexOf('\n') >= 0))
out.flush();
}
}
catch (InterruptedIOException x) {
Thread.currentThread().interrupt();
}
catch (IOException x) {
trouble = true;
}
}
public void println(Object x) {
String s = String.valueOf(x);
synchronized (this) {
print(s);
newLine();
}
}
public static String valueOf(Object obj) {
return (obj == null) ? "null" : obj.toString();
}
public String toString() {
return getClass().getName() + "@" + Integer.toHexString(hashCode());
}
public void println(char x[]) {
synchronized (this) {
print(x);
newLine();
}
}
public void print(char s[]) {
write(s);
}
private void write(char buf[]) {
try {
synchronized (this) {
ensureOpen();
textOut.write(buf);
textOut.flushBuffer();
charOut.flushBuffer();
if (autoFlush) {
for (int i = 0; i < buf.length; i++)
if (buf[i] == '\n')
out.flush();
}
}
}
catch (InterruptedIOException x) {
Thread.currentThread().interrupt();
}
catch (IOException x) {
trouble = true;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有