Import Static Ѻ
:: ¹ҡѹ :: Java 2 v 5.0 (Tiger)
หน้า 1 จาก 1
Import Static Ѻ
ػ
import static Static.Msg.MIXED; // Ẻ 1. import ͵Ƿ Static
import static Static.Msg.*; // Ẻ 2. import ֧ͤ ö ¡ءǹ Static class Msg
static s ¶֧ keyword Ѻ
Static S ˭¶֧ Package Static Ѻ
package Static;
public class Msg {
public static final int UPPER =1;
public static final int LOWER =2;
public static final int MIXED=3;
private String msg;
public static void St(){
System.out.print("ʴդѺ");
}
}
---------------------package Static2;
import Static.*;
public class Start {
public static void main(String[] args) {
System.out.println(" Static is " Msg.MIXED); // Static is 3
}
}
แก้ไขล่าสุดโดย Admin เมื่อ Thu May 22, 2008 10:33 am, ทั้งหมด 2 ครั้ง
Re: Import Static Ѻ
package Static2;
import Static.*;
public class Start {
public static void main(String[] args) {
// System.out.println(" Static is "+Msg.MIXED);
Msg.St();
}
}
----------------------
ʴդѺ
import Static.*;
public class Start {
public static void main(String[] args) {
// System.out.println(" Static is "+Msg.MIXED);
Msg.St();
}
}
----------------------
ʴդѺ
Re: Import Static Ѻ
package Static2;
import static Static.Msg.St;
// import Static.Msg.St; Error
public class Start {
public static void main(String[] args) {
St(); // ¡
}
}
import static Static.Msg.St;
// import Static.Msg.St; Error
public class Start {
public static void main(String[] args) {
St(); // ¡
}
}
Re: Import Static Ѻ
package Static2;
import Static.Msg.*;
// import static Static.Msg.St;
// import Static.Msg.St;
public class Start {
public static void main(String[] args) {
System.out.println(" Msg.UPPER : "+Msg.UPPER);
St(); // import Static.*; ÷Ѵ Error St(); Staic
}
}
¹
import Static.*;
import static Static.Msg.*;
Compile Error
import Static.Msg.*;
// import static Static.Msg.St;
// import Static.Msg.St;
public class Start {
public static void main(String[] args) {
System.out.println(" Msg.UPPER : "+Msg.UPPER);
St(); // import Static.*; ÷Ѵ Error St(); Staic
}
}
¹
import Static.*;
import static Static.Msg.*;
Compile Error
Re: Import Static Ѻ
package Static2;
import static Static.Msg.*;
// import static Static.Msg.St;
// import Static.Msg.St;
public class Start {
public static void main(String[] args) {
// System.out.println(" Static is "+Msg.MIXED);
// St();
System.out.println(" Msg.UPPER : "+Msg.UPPER); // error
System.out.println(" Msg.UPPER : "+UPPER);
St();
}
}
import static Static.Msg.*;
// import static Static.Msg.St;
// import Static.Msg.St;
public class Start {
public static void main(String[] args) {
// System.out.println(" Static is "+Msg.MIXED);
// St();
System.out.println(" Msg.UPPER : "+Msg.UPPER); // error
System.out.println(" Msg.UPPER : "+UPPER);
St();
}
}
:: ¹ҡѹ :: Java 2 v 5.0 (Tiger)
หน้า 1 จาก 1
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ