ݺߣ

ݺߣShare a Scribd company logo
Java SE Lesson 9

1.   Ҫʹ÷䣬ҪôӦ Class 
2.   ȡijijӦ Class ijõ 3 ַʽ
a)   ʹ Class ľ̬ forNameClass.forName(java.lang.String);
b)   ʹ.class ﷨String.class;
c)   ʹö getClass()String s = aa; Class<?> clazz = s.getClass();
3.   ͨIJĹ췽ɶַʽ
a)   Ȼ Class Ȼͨ Class  newInstance()ֱɼɣ
     Class<?> classType = String.class;
     Object obj = classType.newInstance();
b) Ȼ Class ȻͨööӦ Constructor ͨ Constructor
    newInstance()ɣ
   Class<?> classType = Customer.class;
   Constructor cons = classType.getConstructor(new Class[]{});
   Object obj = cons.newInstance(new Object[]{});
4. ͨĴĹ췽ɶֻʹһַʽ
   Class<?> classType = Customer.class;
   Constructor cons = classType.getConstructor(new Class[]{String.class, int.class});
   Object obj = cons.newInstance(new Object[]{hello, 3});
5. Integer.TYPE ص int Integer.class ص Integer Ӧ Class

More Related Content

Viewers also liked (18)

Bases de datoBases de dato
Bases de dato
Diego Aramndo rueda
?
Stratesys - Flyer QA-CAPA - SEP2014 ENG
Stratesys - Flyer QA-CAPA - SEP2014 ENGStratesys - Flyer QA-CAPA - SEP2014 ENG
Stratesys - Flyer QA-CAPA - SEP2014 ENG
StratesysUSA
?
La guerra de los mundosLa guerra de los mundos
La guerra de los mundos
Blanka
?
MINERIA: Cavar nuestra propia tumba con la megaminera?MINERIA: Cavar nuestra propia tumba con la megaminera?
MINERIA: Cavar nuestra propia tumba con la megaminera?
ECUADOR DEMOCRATICO
?
Fusion Resorts - Flyer
Fusion Resorts - FlyerFusion Resorts - Flyer
Fusion Resorts - Flyer
Quan Pham
?
Stockholmsnytt Januari08
Stockholmsnytt Januari08Stockholmsnytt Januari08
Stockholmsnytt Januari08
Maria Lohe
?
App11 draft
App11 draftApp11 draft
App11 draft
guesta850b5
?
Internet historiaInternet historia
Internet historia
Esy Paola Reyes Curi
?
12.1
12.112.1
12.1
picciolim
?
Pest idaPest ida
Pest ida
Veronica Farez
?
Juin 2011Juin 2011
Juin 2011
magic32
?
Van boer tot bord - Wageningen en omstreken in verhalen en recepten
Van boer tot bord - Wageningen en omstreken in verhalen en receptenVan boer tot bord - Wageningen en omstreken in verhalen en recepten
Van boer tot bord - Wageningen en omstreken in verhalen en recepten
Annita van Betuw
?
Global Architects - werk
Global Architects - werkGlobal Architects - werk
Global Architects - werk
arthurnuss
?
Utrecht - Mgr. van de Weteringstraat 96bis
Utrecht - Mgr. van de Weteringstraat 96bisUtrecht - Mgr. van de Weteringstraat 96bis
Utrecht - Mgr. van de Weteringstraat 96bis
Woningadviseurs
?
L43056874
L43056874L43056874
L43056874
IJERA Editor
?
LINEAMIENTOSPARALAORGANIZACI?NYELFUNCIONAMIENTODELOSCONSEJOST?CNICOSESCOLARESLINEAMIENTOSPARALAORGANIZACI?NYELFUNCIONAMIENTODELOSCONSEJOST?CNICOSESCOLARES
LINEAMIENTOSPARALAORGANIZACI?NYELFUNCIONAMIENTODELOSCONSEJOST?CNICOSESCOLARES
Ramiro Murillo
?
Bases de datoBases de dato
Bases de dato
Diego Aramndo rueda
?
Stratesys - Flyer QA-CAPA - SEP2014 ENG
Stratesys - Flyer QA-CAPA - SEP2014 ENGStratesys - Flyer QA-CAPA - SEP2014 ENG
Stratesys - Flyer QA-CAPA - SEP2014 ENG
StratesysUSA
?
La guerra de los mundosLa guerra de los mundos
La guerra de los mundos
Blanka
?
MINERIA: Cavar nuestra propia tumba con la megaminera?MINERIA: Cavar nuestra propia tumba con la megaminera?
MINERIA: Cavar nuestra propia tumba con la megaminera?
ECUADOR DEMOCRATICO
?
Fusion Resorts - Flyer
Fusion Resorts - FlyerFusion Resorts - Flyer
Fusion Resorts - Flyer
Quan Pham
?
Stockholmsnytt Januari08
Stockholmsnytt Januari08Stockholmsnytt Januari08
Stockholmsnytt Januari08
Maria Lohe
?
Internet historiaInternet historia
Internet historia
Esy Paola Reyes Curi
?
Juin 2011Juin 2011
Juin 2011
magic32
?
Van boer tot bord - Wageningen en omstreken in verhalen en recepten
Van boer tot bord - Wageningen en omstreken in verhalen en receptenVan boer tot bord - Wageningen en omstreken in verhalen en recepten
Van boer tot bord - Wageningen en omstreken in verhalen en recepten
Annita van Betuw
?
Global Architects - werk
Global Architects - werkGlobal Architects - werk
Global Architects - werk
arthurnuss
?
Utrecht - Mgr. van de Weteringstraat 96bis
Utrecht - Mgr. van de Weteringstraat 96bisUtrecht - Mgr. van de Weteringstraat 96bis
Utrecht - Mgr. van de Weteringstraat 96bis
Woningadviseurs
?
LINEAMIENTOSPARALAORGANIZACI?NYELFUNCIONAMIENTODELOSCONSEJOST?CNICOSESCOLARESLINEAMIENTOSPARALAORGANIZACI?NYELFUNCIONAMIENTODELOSCONSEJOST?CNICOSESCOLARES
LINEAMIENTOSPARALAORGANIZACI?NYELFUNCIONAMIENTODELOSCONSEJOST?CNICOSESCOLARES
Ramiro Murillo
?

More from ArBing Xie (20)

[ʥ˼԰][Java SE]Swing
[ʥ˼԰][Java SE]Swing[ʥ˼԰][Java SE]Swing
[ʥ˼԰][Java SE]Swing
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 15
[ʥ˼԰][Java SE]Java se lesson 15[ʥ˼԰][Java SE]Java se lesson 15
[ʥ˼԰][Java SE]Java se lesson 15
ArBing Xie
?
[ʥ˼԰][Java SE]Websphere.application.developer(wsad)ʹwin cvs
[ʥ˼԰][Java SE]Websphere.application.developer(wsad)ʹwin cvs[ʥ˼԰][Java SE]Websphere.application.developer(wsad)ʹwin cvs
[ʥ˼԰][Java SE]Websphere.application.developer(wsad)ʹwin cvs
ArBing Xie
?
[ʥ˼԰][Java SE]Strategy
[ʥ˼԰][Java SE]Strategy[ʥ˼԰][Java SE]Strategy
[ʥ˼԰][Java SE]Strategy
ArBing Xie
?
[ʥ˼԰][Java SE]Ooaduml lesson 2
[ʥ˼԰][Java SE]Ooaduml lesson 2[ʥ˼԰][Java SE]Ooaduml lesson 2
[ʥ˼԰][Java SE]Ooaduml lesson 2
ArBing Xie
?
[ʥ˼԰][Java SE]Observer
[ʥ˼԰][Java SE]Observer[ʥ˼԰][Java SE]Observer
[ʥ˼԰][Java SE]Observer
ArBing Xie
?
[ʥ˼԰][Java SE]Network
[ʥ˼԰][Java SE]Network[ʥ˼԰][Java SE]Network
[ʥ˼԰][Java SE]Network
ArBing Xie
?
[ʥ˼԰][Java SE]Jdk5
[ʥ˼԰][Java SE]Jdk5[ʥ˼԰][Java SE]Jdk5
[ʥ˼԰][Java SE]Jdk5
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 22
[ʥ˼԰][Java SE]Java se lesson 22[ʥ˼԰][Java SE]Java se lesson 22
[ʥ˼԰][Java SE]Java se lesson 22
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 21
[ʥ˼԰][Java SE]Java se lesson 21[ʥ˼԰][Java SE]Java se lesson 21
[ʥ˼԰][Java SE]Java se lesson 21
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 20
[ʥ˼԰][Java SE]Java se lesson 20[ʥ˼԰][Java SE]Java se lesson 20
[ʥ˼԰][Java SE]Java se lesson 20
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 17
[ʥ˼԰][Java SE]Java se lesson 17[ʥ˼԰][Java SE]Java se lesson 17
[ʥ˼԰][Java SE]Java se lesson 17
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 16
[ʥ˼԰][Java SE]Java se lesson 16[ʥ˼԰][Java SE]Java se lesson 16
[ʥ˼԰][Java SE]Java se lesson 16
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 13
[ʥ˼԰][Java SE]Java se lesson 13[ʥ˼԰][Java SE]Java se lesson 13
[ʥ˼԰][Java SE]Java se lesson 13
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 12
[ʥ˼԰][Java SE]Java se lesson 12[ʥ˼԰][Java SE]Java se lesson 12
[ʥ˼԰][Java SE]Java se lesson 12
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 11
[ʥ˼԰][Java SE]Java se lesson 11[ʥ˼԰][Java SE]Java se lesson 11
[ʥ˼԰][Java SE]Java se lesson 11
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 10
[ʥ˼԰][Java SE]Java se lesson 10[ʥ˼԰][Java SE]Java se lesson 10
[ʥ˼԰][Java SE]Java se lesson 10
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 8
[ʥ˼԰][Java SE]Java se lesson 8[ʥ˼԰][Java SE]Java se lesson 8
[ʥ˼԰][Java SE]Java se lesson 8
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 5
[ʥ˼԰][Java SE]Java se lesson 5[ʥ˼԰][Java SE]Java se lesson 5
[ʥ˼԰][Java SE]Java se lesson 5
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 4
[ʥ˼԰][Java SE]Java se lesson 4[ʥ˼԰][Java SE]Java se lesson 4
[ʥ˼԰][Java SE]Java se lesson 4
ArBing Xie
?
[ʥ˼԰][Java SE]Swing
[ʥ˼԰][Java SE]Swing[ʥ˼԰][Java SE]Swing
[ʥ˼԰][Java SE]Swing
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 15
[ʥ˼԰][Java SE]Java se lesson 15[ʥ˼԰][Java SE]Java se lesson 15
[ʥ˼԰][Java SE]Java se lesson 15
ArBing Xie
?
[ʥ˼԰][Java SE]Websphere.application.developer(wsad)ʹwin cvs
[ʥ˼԰][Java SE]Websphere.application.developer(wsad)ʹwin cvs[ʥ˼԰][Java SE]Websphere.application.developer(wsad)ʹwin cvs
[ʥ˼԰][Java SE]Websphere.application.developer(wsad)ʹwin cvs
ArBing Xie
?
[ʥ˼԰][Java SE]Strategy
[ʥ˼԰][Java SE]Strategy[ʥ˼԰][Java SE]Strategy
[ʥ˼԰][Java SE]Strategy
ArBing Xie
?
[ʥ˼԰][Java SE]Ooaduml lesson 2
[ʥ˼԰][Java SE]Ooaduml lesson 2[ʥ˼԰][Java SE]Ooaduml lesson 2
[ʥ˼԰][Java SE]Ooaduml lesson 2
ArBing Xie
?
[ʥ˼԰][Java SE]Observer
[ʥ˼԰][Java SE]Observer[ʥ˼԰][Java SE]Observer
[ʥ˼԰][Java SE]Observer
ArBing Xie
?
[ʥ˼԰][Java SE]Network
[ʥ˼԰][Java SE]Network[ʥ˼԰][Java SE]Network
[ʥ˼԰][Java SE]Network
ArBing Xie
?
[ʥ˼԰][Java SE]Jdk5
[ʥ˼԰][Java SE]Jdk5[ʥ˼԰][Java SE]Jdk5
[ʥ˼԰][Java SE]Jdk5
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 22
[ʥ˼԰][Java SE]Java se lesson 22[ʥ˼԰][Java SE]Java se lesson 22
[ʥ˼԰][Java SE]Java se lesson 22
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 21
[ʥ˼԰][Java SE]Java se lesson 21[ʥ˼԰][Java SE]Java se lesson 21
[ʥ˼԰][Java SE]Java se lesson 21
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 20
[ʥ˼԰][Java SE]Java se lesson 20[ʥ˼԰][Java SE]Java se lesson 20
[ʥ˼԰][Java SE]Java se lesson 20
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 17
[ʥ˼԰][Java SE]Java se lesson 17[ʥ˼԰][Java SE]Java se lesson 17
[ʥ˼԰][Java SE]Java se lesson 17
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 16
[ʥ˼԰][Java SE]Java se lesson 16[ʥ˼԰][Java SE]Java se lesson 16
[ʥ˼԰][Java SE]Java se lesson 16
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 13
[ʥ˼԰][Java SE]Java se lesson 13[ʥ˼԰][Java SE]Java se lesson 13
[ʥ˼԰][Java SE]Java se lesson 13
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 12
[ʥ˼԰][Java SE]Java se lesson 12[ʥ˼԰][Java SE]Java se lesson 12
[ʥ˼԰][Java SE]Java se lesson 12
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 11
[ʥ˼԰][Java SE]Java se lesson 11[ʥ˼԰][Java SE]Java se lesson 11
[ʥ˼԰][Java SE]Java se lesson 11
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 10
[ʥ˼԰][Java SE]Java se lesson 10[ʥ˼԰][Java SE]Java se lesson 10
[ʥ˼԰][Java SE]Java se lesson 10
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 8
[ʥ˼԰][Java SE]Java se lesson 8[ʥ˼԰][Java SE]Java se lesson 8
[ʥ˼԰][Java SE]Java se lesson 8
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 5
[ʥ˼԰][Java SE]Java se lesson 5[ʥ˼԰][Java SE]Java se lesson 5
[ʥ˼԰][Java SE]Java se lesson 5
ArBing Xie
?
[ʥ˼԰][Java SE]Java se lesson 4
[ʥ˼԰][Java SE]Java se lesson 4[ʥ˼԰][Java SE]Java se lesson 4
[ʥ˼԰][Java SE]Java se lesson 4
ArBing Xie
?

Recently uploaded (6)

Cantonmade 2025 Hotel Supplier Catalog: Technical Specs for Engineers & Integ...
Cantonmade 2025 Hotel Supplier Catalog: Technical Specs for Engineers & Integ...Cantonmade 2025 Hotel Supplier Catalog: Technical Specs for Engineers & Integ...
Cantonmade 2025 Hotel Supplier Catalog: Technical Specs for Engineers & Integ...
RayChan91
?
2025 DeveloperWeek - The Sound of Innovation: Why Voice Cloning Will Redefine...
2025 DeveloperWeek - The Sound of Innovation: Why Voice Cloning Will Redefine...2025 DeveloperWeek - The Sound of Innovation: Why Voice Cloning Will Redefine...
2025 DeveloperWeek - The Sound of Innovation: Why Voice Cloning Will Redefine...
David vonThenen
?
2025 NVIDIA GTC: Crack the AI Black Box: Practical Techniques for Explainable AI
2025 NVIDIA GTC: Crack the AI Black Box: Practical Techniques for Explainable AI2025 NVIDIA GTC: Crack the AI Black Box: Practical Techniques for Explainable AI
2025 NVIDIA GTC: Crack the AI Black Box: Practical Techniques for Explainable AI
David vonThenen
?
ѧҵ֤(Ǵѧλ֤ѧ֤ѧ)
ѧҵ֤(Ǵѧλ֤ѧ֤ѧ)ѧҵ֤(Ǵѧλ֤ѧ֤ѧ)
ѧҵ֤(Ǵѧλ֤ѧ֤ѧ)
kaozytf
?
ƥȱѧҵ֤(ʱհѧλ֤ҵ֤)
ƥȱѧҵ֤(ʱհѧλ֤ҵ֤)ƥȱѧҵ֤(ʱհѧλ֤ҵ֤)
ƥȱѧҵ֤(ʱհѧλ֤ҵ֤)
kaozytf
?
Build_With_AI_2025 Gemini 2.0 New Function
Build_With_AI_2025  Gemini 2.0 New FunctionBuild_With_AI_2025  Gemini 2.0 New Function
Build_With_AI_2025 Gemini 2.0 New Function
kevinchiu59
?
Cantonmade 2025 Hotel Supplier Catalog: Technical Specs for Engineers & Integ...
Cantonmade 2025 Hotel Supplier Catalog: Technical Specs for Engineers & Integ...Cantonmade 2025 Hotel Supplier Catalog: Technical Specs for Engineers & Integ...
Cantonmade 2025 Hotel Supplier Catalog: Technical Specs for Engineers & Integ...
RayChan91
?
2025 DeveloperWeek - The Sound of Innovation: Why Voice Cloning Will Redefine...
2025 DeveloperWeek - The Sound of Innovation: Why Voice Cloning Will Redefine...2025 DeveloperWeek - The Sound of Innovation: Why Voice Cloning Will Redefine...
2025 DeveloperWeek - The Sound of Innovation: Why Voice Cloning Will Redefine...
David vonThenen
?
2025 NVIDIA GTC: Crack the AI Black Box: Practical Techniques for Explainable AI
2025 NVIDIA GTC: Crack the AI Black Box: Practical Techniques for Explainable AI2025 NVIDIA GTC: Crack the AI Black Box: Practical Techniques for Explainable AI
2025 NVIDIA GTC: Crack the AI Black Box: Practical Techniques for Explainable AI
David vonThenen
?
ѧҵ֤(Ǵѧλ֤ѧ֤ѧ)
ѧҵ֤(Ǵѧλ֤ѧ֤ѧ)ѧҵ֤(Ǵѧλ֤ѧ֤ѧ)
ѧҵ֤(Ǵѧλ֤ѧ֤ѧ)
kaozytf
?
ƥȱѧҵ֤(ʱհѧλ֤ҵ֤)
ƥȱѧҵ֤(ʱհѧλ֤ҵ֤)ƥȱѧҵ֤(ʱհѧλ֤ҵ֤)
ƥȱѧҵ֤(ʱհѧλ֤ҵ֤)
kaozytf
?
Build_With_AI_2025 Gemini 2.0 New Function
Build_With_AI_2025  Gemini 2.0 New FunctionBuild_With_AI_2025  Gemini 2.0 New Function
Build_With_AI_2025 Gemini 2.0 New Function
kevinchiu59
?

[ʥ˼԰][Java SE]Java se lesson 9

  • 1. Java SE Lesson 9 1. Ҫʹ÷䣬ҪôӦ Class 2. ȡijijӦ Class ijõ 3 ַʽ a) ʹ Class ľ̬ forNameClass.forName(java.lang.String); b) ʹ.class ﷨String.class; c) ʹö getClass()String s = aa; Class<?> clazz = s.getClass(); 3. ͨIJĹ췽ɶַʽ a) Ȼ Class Ȼͨ Class newInstance()ֱɼɣ Class<?> classType = String.class; Object obj = classType.newInstance(); b) Ȼ Class ȻͨööӦ Constructor ͨ Constructor newInstance()ɣ Class<?> classType = Customer.class; Constructor cons = classType.getConstructor(new Class[]{}); Object obj = cons.newInstance(new Object[]{}); 4. ͨĴĹ췽ɶֻʹһַʽ Class<?> classType = Customer.class; Constructor cons = classType.getConstructor(new Class[]{String.class, int.class}); Object obj = cons.newInstance(new Object[]{hello, 3}); 5. Integer.TYPE ص int Integer.class ص Integer Ӧ Class