java最终类最终方法_java getclass_Java对象类最终类的getClass()方法(带示例)

java getclass

对象类最终类getClass() (Object Class final Class getClass())

This method is available in java.lang.Object.getClass(). 此方法在java.lang.Object.getClass()中可用。 This method is used to returns the Class class object.  此方法用于返回Class类对象。 The returned Class object is the object that is locked by static synchronized methods of the given class.  返回的Class对象是由给定类的静态同步方法锁定的对象。 This method is final so we can't override it. 此方法是最终方法,因此我们无法覆盖它。

Syntax:

句法:

final Class getClass(){

}

Parameter(s):

参数:

We don't pass any object as a parameter in the method of the Object class.

我们没有在Object类的方法中将任何对象作为参数传递。

Return value:

返回值:

The return type of this method is Class that means this method returns Class object.

该方法的返回类型为Class ,这意味着该方法返回Class对象。

Java程序演示Object Class getClass()方法的示例 (Java program to demonstrate example of Object Class getClass() method)

import java.lang.Object;

public class ObjectClass {

// Java program to demonstrate working of

// getClass() method of Object class

public static void main(String[] args) {

Float fl = new Float(10.f);

Class cl = fl.getClass();

System.out.println("The name of Class of Float fl is : " +

cl.getName());

}

}

Output

输出量

D:\Programs>javac ObjectClass.java

D:\Programs>java ObjectClass

The name of Class of Float fl is : java.lang.Float

翻译自: https://www.includehelp.com/java/object-class-final-class-getclass-method-with-example.aspx

java getclass

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值