原始类型和引用类型之间有什么区别? [英] What's the difference between primitive and reference types?
问题描述
这是一个过去的考试问题,我想知道原始类型和参考类型首先是什么?
使用数组我知道引用类型是数组由对象或变量组成的位置,但是基本类型是用int或strings创建数组的地方。 (对吗?)
This is a past exam question and I was wondering what a primitive type and reference type are first off? With an array I know the a reference type is where the array is composed of objects or variables, but a primitive type is where you would create the array with just int or strings. (right?)
您认为您如何回答测试中的问题并获得良好的信誉?没有真正直接引用原始的ARRAY类型......有没有办法在没有它的情况下做到这一点?或者你认为用数组解释它会没问题。
How do you think you would answer the question on the test and be given good credit? Without really referring directly to an primitive ARRAY type... Is there a way to do it without that? Or do you think it would be fine to just explain it with the array.
推荐答案
这些是Java中的原始类型:
These are the primitive types in Java:
- boolean
- byte
- short
- char
- int
- long
- float
- double
- boolean
- byte
- short
- char
- int
- long
- float
- double
所有其他类型都是引用类型:它们引用对象。
All the other types are reference types: they reference objects.
这是关于语言基础知识的Java教程的第一部分。
这篇关于原始类型和引用类型之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!