可以在Java中创建新的原始数据类型 [英] Can Create a New primitive datatype in Java

查看:53
本文介绍了可以在Java中创建新的原始数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先要在这里澄清一下,这个问题是出于好奇.我没有遇到任何问题.

First thing I want to clarify here, this question is because of curiosity. I am not facing any issue.

Java byte short int 等中有许多原始类型可用.现在假设我想创建一个新的原始类型(例如 mediumint 或其他任何内容).我们可以做到吗?如果是,那怎么办?

There are many primitive types available in Java byte, short, int, etc. Now suppose I want to create a new primitive type (e.g. mediumint or anything else). Can we do that? If yes then how?

推荐答案

原始类型是语言本身定义的类型.在 Java 中,您只能将新类型定义为 Class ,它们都是从称为 Object 的通用基类派生的.

Primitive types are the ones defined by the language itself. In Java you can only define new types as Classes all derived from the common base class called Object.

这篇关于可以在Java中创建新的原始数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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