如果不使用返回值,Class.forName() 有什么作用? [英] What purpose does Class.forName() serve if you don't use the return value?

查看:18
本文介绍了如果不使用返回值,Class.forName() 有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用商业 JDBC 驱动程序的示例应用程序中看到了这一行:

I've seen this line in a sample application for using a commercial JDBC driver:

Class.forName("name.of.a.jcdb.driver")

未使用返回值.

这条线有什么用途?

推荐答案

它执行该类的静态加载.所以 static { } 块中的任何内容都会运行.

It performs a static loading of that class. So anything in the static { } block, will run.

这篇关于如果不使用返回值,Class.forName() 有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆