Class and class and getClass ()

2010-03-28  来源:本站原创  分类:Java  人气:196 

Small class is a keyword, such as public class Student ()

Class is a great class, defined as public final class Class ()

getClass () is an instance of the class through to return to its corresponding Class object class, such as str.getClass ()

Each class has a Class object, to get a class Class object There are three ways.
1: The instance of the class call the getClass ()
Student st;
Class cls = st.getClass ();

2: kind of class member variables and an equivalent
Class cls = Student.class;
3: Class static methods forName (String)
String className = "Student";
Class cls = Class.forName (className);

相关文章
  • Class and class and getClass () 2010-03-28

    Small class is a keyword, such as public class Student () Class is a great class, defined as public final class Class () getClass () is an instance of the class through to return to its corresponding Class object class, such as str.getClass () Each c

  • Object getClass () method 2010-04-24

    We all know that side dishes concludes Object class has a getClass () method to open API to see if it reads Back to the runtime class of this Object. Back to the Class object is expressed by a class of static synchronized method locks the object. Bac

  • this.getClass () and getResourceAsStream () to load the essence of class 2010-12-31

    (1). new FileInputStream ("a.txt") Well, this should be in the works a.txt root directory. For example: test_files/wdag0437ir.zip (2). this.getClass (). getClassLoader (). getResourceAsStream ("a.txt") This is also in the bin directory

  • class literal & instance.getClass () & Class.forName (String className) 2011-04-20

    Several commonly used methods to obtain Class instance of the class: 1 class literal (class literal) 2 instanceOfClass.getClass (); 3 Class.forName (String className) 4 classLoaderInstance.loadClass (String name, boolean resolve) 34 for explicit dyna

  • super.getClass () trap 2011-09-18

    First given a problem, the following program output is the number? import java.util.Date; public class Test extends Date{ public static void main(String[] args) { new Test().test(); } public void test(){ System.out.println(super.getClass().getName())

  • java中instanceof和getClass()的区别分析 2013-11-14

    本篇文章介绍了,在java中instanceof和getClass()的区别分析.需要的朋友参考下 class A { } class B extends A { } Object o1 = new A(); Object o2 = new B(); o1 instanceof A => true o1 instanceof B => false o2 instanceof A => true // <================ HERE o2 instanceof B =&

  • Java反射学习 getClass()函数应用 2014-02-15

    所谓反射,可以理解为在运行时期获取对象类型信息的操作,本文将详细介绍,需要的朋友可以参考下 Java反射学习 所谓反射,可以理解为在运行时期获取对象类型信息的操作.传统的编程方法要求程序员在编译阶段决定使用的类型,但是在反射的帮助下,编程人员可以动态获取这些信息,从而编写更加具有可移植性的代码.严格地说,反射并非编程语言的特性,因为在任何一种语言都可以实现反射机制,但是如果编程语言本身支持反射,那么反射的实现就会方便很多. 1,获得类型类 我们知道在Java中一切都是对象,我们一般所使用的对象都

  • Java在不同环境下获取当前路径的方法--this.getClass().getResource("") 2012-03-09

    1. 在Servlet/Filter等Servlet web环境中,只要获得javax.servlet.ServletContext类型,则可以通过 getRealPath("...") 获得路径.相对路径中最顶层目录可通过参数""/""获取. request.getSession().getServletContext().getRealPath("/"); 2. JSP自定义标签javax.servlet.jsp.tage

  • getClass().getClassLoader()和this.class.getClass... 2012-07-02

    InputStream is = getClass().getClassLoader().getResourceAsStream("helloworld.properties"); InputStream is = this.class.getClassLoader().getResourceAsStream("helloworld.properties"); 两种写法都是为了将helloworld.properties配置文件转化成InputStream,写法比较

  • Java Class.forName.Class.class.getClass示例区分 2013-09-11

    本文标签: Class.forName.Class.class.getClass 差异: 1.出现的时期不同:Class.forName()在运行时加载:Class.class和getClass()是在编译器加载 2.Class.class只是在编译时用来存放类的相关信息,并没有实例化对象:而getClass()既实例化了对象,又存放了类信息 3.例: Test t=new Test(); Class c=t.getClass(); Class c=Class.class; Class c=Cl

  • 对getClass的理解 2014-03-20

    之前看过一些博客,大致记得java加载器是bootstrap .extension和Application(又叫System加载器).用我那匮乏的词汇说就是先委托父加载器,实在找不到这个类再加载自己.bootstrap用来加载rt.jar(记得大二时非要在没JVM的环境下运行java,用GREEN JVM时记得这个包有90M,因为主要的类都在这里).extension加载的类是在jre/lib/ext,system是classpath下的东东.其实类和类的区别主要看是不是用同一个加载器加载的,如

  • this.getClass().getResource() 2014-07-15

    this.getClass().getResource() package test; import org.junit.Test; import java.io.File; import java.net.URL; /** * Created with IntelliJ IDEA. * User: ASUS * Date: 14-7-3 * Time: 下午1:46 * To change this template use File | Settings | File Templates.

  • hibernate generic generic DAO 2009-02-27

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1

  • jboss ejb3 Message Driven Bean 2009-02-27

    Super Medium ejb hate. . . . . . . . . . . . . . . . . . . ================================================ To configure a Message Driven Bean in a different application server parameters are not the same. Currently only passed the test jboss. Messag

  • To a generic hibernate example DAO 2009-02-28

    Reprint: http://blog.csdn.net/dingx package sgf4web.dao; import java.io.Serializable; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.hibernate.*; import org.hibernate.criterion.*; import org.springframe

  • A javascript formatting tools 2009-03-24

    Writing of one strong man, will not know a really good make. <html> <head> <title>JSFormatting tools </title> <meta http-equiv="content-type" content="text/html; charset=gb2312" /> <style> * { paddin

  • GWT's gwt-dev-windows.jar call key js 2009-03-25

    Through repeated follow-up, gwt-dev-windows used in the service container embedded version of Tomcat, as to how to run a lot of embedded Tomcat web here to say the least, this is only guide text, and guide how foreigners look the code is how to writt

  • java 2009-03-29

    Five useful filter 1, so that browser does not cache the page filters import javax.servlet .*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; / ** * For the Browser does not cache the page so that the filters * / public cl

  • jdbc connection pool easy package 2009-04-03

    The main methods of implementation are: The use of a container (LinkedList), initialization time set number of connections to generate Connection objects on the container Each subsequent time to obtain connections from the container to obtain, but th

  • hibernate study of the thirteenth chapter 2009-04-05

    load method and principle analysis of lazy loading The purpose of lazy loading, to reduce unnecessary database queries and enhance performance. Mapping components to use in front of the user category, the Writing test code to do to change: public cla