2013年12月8日星期日

Will Class Is used for what .

 This post last edited by hz890 on 2012-10-09 16:12:54
job needs, currently just starting out with Java, when using JDBC, and saw under the CallableStatement object has getObject (String parameterName, Map > map) methods. Now do not understand
Class is what's the use , why you want to use in the Class Yeah !
The question mark What does it mean ?

Thank you out!
------ Solution ---------------------------------------- ----
some containers can put any object , such as List, but then take the time to do type conversion. If in a statement when the specified type , then do not need to take the time to do the type of strong turn .

List list = new ArrayList ();
------ Solution ---------------- ----------------------------
recommend you look at the generic
------ Solution --- -----------------------------------------
generic parameter types are also can be wildcard type .
such Class classType = Class.forName ("java.lang.String") ;
"?" on behalf of an unknown type
------ Solution ------------------------------ --------------
public final class Class extends Objectimplements Serializable, GenericDeclaration, Type, said it is a class instance AnnotatedElementClass Java applications running classes and interfaces . Enumeration is a class annotation is an interface . Each array is mapped to the Class object belongs to a class , all the elements of the array with the same type and dimensions are sharing the Class object. Basic Java types (boolean, byte, char, short, int, long, float and double) and a keyword void are also represented as Class objects.

Class no public constructor. Class objects are loaded at the time by the Java Virtual Machine and class by calling the class loader defineClass method of automatically constructed .

The following example uses a Class object to display the object's class name:


void printClassName (Object obj) {
System.out.println ("The class of" + obj +
"is" + obj.getClass () getName ()).;
}
You can also use a class literal (JLS Section 15.8.2) to obtain the specified type ( or void) the Class object. For example:


System.out.println ("The name of class Foo is:" + Foo.class.getName ());

------ Solution ------------------------------------ --------
java.lang
class Class
java.lang.Object
java.lang.Class
type parameter :
T - Class object modeling by this type of class. For example , String.class type is Class . If a class is to be modeled is unknown , use Class .

------ Solution ------------------------------------ --------
Class class is generally used for reflection , < > indicates a generic ? wildcard
------ Solution ---------- ----------------------------------
upstairs said it right !
------ For reference only -------------------------------------- -
generic , which means that a certain type of Object.
------ For reference only -------------------------------------- -
 Yes, that is right upstairs right

没有评论:

发表评论