提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
类字段的默认初始化
public class Main { byte b; short s; /** from * 时代Java **/ int i; long l; float f; double d; boolean bool; String str; public static void main(String[] args) { // Create an object of DefaultInit class Main obj = new Main(); /*来自 时 代 J a v a 公 众 号 - nowjava.com*/ // Print the default values for all instance variables System.out.println("byte is initialized to " + obj.l); System.out.println("short is initialized to " + obj.s); System.out.println("int is initialized to " + obj.i); System.out.println("long is initialized to " + obj.l); System.out.println("float is initialized to " + obj.f); System.out.println(