📄 15.1.html
字号:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Weng Kai">
<TITLE>Class object</TITLE>
</HEAD>
<BODY>
<H1>15.1 Class object</H1>
<HR WIDTH="100%">
The Class object is used to create all of the "regular" objects of your class.
<p>
Each time you write a new class, a single Class object is also created (and stored, appropriately enough, in an identically named .class file). At run time, when you want to make an object of that class, the Java Virtual Machine (JVM) that's executing your program first checks to see if the Class object for that type is loaded. If not, the JVM loads it by finding the .class file with that name.
<p>
Case Study: <a href=case/SweetShop.java>SweetShop.java</a>
<p>
The output of this program for one JVM is:
<pre>
inside main
Loading Candy
After creating Candy
Loading Gum
After Class.forName("Gum")
Loading Cookie
After creating Cookie
</pre>
<p>
In Java 1.1 you have a second way to produce the handle to the Class object: use the class literal. In the above program this would look like:
<pre>Gum.class;</pre>
<HR WIDTH="100%">
<DIV ALIGN=right><A HREF="15.2.html">Next Page</A></DIV>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -