Wrapper Classes 是否被视为对象?或者他们只是 Class? (JAVA)

Are Wrapper Classes considered Objects? Or are they just Class? (JAVA)

我一直在寻找关于这个的答案,但我很不幸。

我有点困惑,因为我的教授教我的东西与我从网上学到的东西相矛盾。

据我所知,整数、双精度、浮点数、字符等都是包装器 'Classes'。然而,我的大学教授一直将其称为对象。我还可以包括他也称数学为对象。

这里有一些他是怎么说的例子:

"要获取一个int的绝对值,我们需要从Math object中调用abs()方法"

“在Integer.parseInt()中,整数是一个对象,而parseInt()是方法。”

那么,Wrapper 类 可以称为对象吗?

抱歉,如果这应该是容易理解的事情。我只是很困惑,因为 iirc 他称为对象的那些被称为 类。

“对象”通常指的是 classes 的实例,但有时 classes 和对象这两个术语可以互换使用,所以这可能就是您的教授正在发生的事情。有 Integer、Float 等 classes,您可以实例化它们以生成 Integer、float 等对象。 例如:

Integer num = new Integer(5); //"Integer" is the class and you are instantiating that class to make an Integer object called "num"
int n = Integer.parseInt("5"); //"Integer" is the class and you are calling the static method of that class "parseInt" which returns an int 

数学 class 是一个您无法实例化的 class,因为它没有构造函数。它只有可以调用的静态方法。由于您无法将其实例化为对象,因此在技术上将其称为对象是不合适的。