//////TestMain.java:::: package com.main; import com.bean.Test; public class TestMain { public static void main(String[] args) { Test stu1=new Test(); System.out.println("8种基本类型的初始值:"); System.out.println("byte:"+stu1.getBytes()); System.out.println("short:"+stu1.getShorts()); System.out.println("int:"+stu1.getInts()); System.out.println("long:"+stu1.getLongs()); System.out.println("float:"+stu1.getFloats()); System.out.println("double:"+stu1.getDoubles()); System.out.println("char:"+stu1.getChars()); System.out.println("boolean:"+stu1.isBooleans()); System.out.println("引用数据类型:"); System.out.println("String:"+stu1.getStr()); int[] aa=stu1.getA(); System.out.println("a[0]:"+aa[0]); char[] cha=stu1.getCha(); System.out.println("cha[0]:"+cha[0]); } } //////Test.java::::: package com.bean; public class Test { //8种基本数据类型 private byte bytes; private short shorts; private int ints; private long longs; private float floats; private double doubles; private char chars; private boolean booleans; public byte getBytes() { return bytes; } public void setBytes(byte bytes) { this.bytes = bytes; } public short getShorts() { return shorts; } public void setShorts(short shorts) { this.shorts = shorts; } public int getInts() { return ints; } public void setInts(int ints) { this.ints = ints; } public long getLongs() { return longs; } public void setLongs(long longs) { this.longs = longs; } public float getFloats() { return floats; } public void setFloats(float floats) { this.floats = floats; } public double getDoubles() { return doubles; } public void setDoubles(double doubles) { this.doubles = doubles; } public char getChars() { return chars; } public void setChars(char chars) { this.chars = chars; } public boolean isBooleans() { return booleans; } public void setBooleans(boolean booleans) { this.booleans = booleans; } //引用数据类型 private String str; private int[] a=new int[4]; private char[] cha=new char[4]; public char[] getCha() { return cha; } public void setCha(char[] cha) { this.cha = cha; } public int[] getA() { return a; } public void setA(int[] a) { this.a = a; } public String getStr() { return str; } public void setStr(String str) { this.str = str; } }