הדפסת ערך של Property ב- JAVA
אני רוצה להשתמש ב- property בתוכנית שאני כותב ולכן כדי לבחון את זה כתבתי קוד קצר:
אני רוצה להשתמש ב- property בתוכנית שאני כותב ולכן כדי לבחון את זה כתבתי קוד קצר:
import java.util.*; public class Test_dir { private Properties table; public Test_dir() { printProp(); } public void printProp() { table=new Properties(); Object val=table.getProperty("test"); if (val!=null) System.out.println(val.toString()); else System.out.println("no property"); } public static void main(String[] args) { Test_dir app=new Test_dir(); } }
אני מריץ את התוכנית כך:java -Dtest=chen Test_dir
והפלט הוא no property מה לא בסדר בקוד שרשמתי? תודה מראש, חן.