//個人第一個java程序 /**the first thinking in java example program * display a string and today's date * @author Administrator * @version 4.0 */ public class HelloDate { /**entrv point to class & application. * @param args array of string arguments * @throws exceptions no exceptions thrown */ public static void main(String[] args){ System.out.println("Hello, it's"); System.out.println(new Date()); } }/* output:(55% match) hello.it's wed oct */ //第二個 public class ATypeName { public static void main(String[] args) { ATypeName a=new ATypeName(); System.out.println(a); } } //類,對象,新建實例,輸出 public class DataOnly { int i; double d; boolean b; public static void main(String[] args) { DataOnly data=new DataOnly(); data.i=47; data.d=1.1; data.b=false; System.out.println(data.i); System.out.println(data.d); System.out.println(data.b); } } //靜態變量,靜態方法 class StaticTest { static int i=47; } public class Incrementable { static void increment() {StaticTest.i++;} public static void main(String[] args) { Incrementable sf=new Incrementable(); System.out.println(StaticTest.i+""); } } //書上例題 public class ShowProperties { public static void main(String[] args) { System.getProperties().list(System.out); System.out.println(System.getProperty("user.name")); System.out.println( System.getProperty("java.library.path")); } } //課後習題,建立一個類,它包含一個int域和float域,他們都沒有初始化,將他們的值打印出來,已驗證JAVA執行了默認初始化 public class test1 { int i; float str; public int getI(){ return i; } public float getstr(){ return str; } public static void main(String[] args) { System.out.println(new test1().getI()); System.out.println(new test1().getstr()); } }