原始类型和引用类型有什么区别? [英] What's the difference between primitive and reference types?

查看:28
本文介绍了原始类型和引用类型有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个过去的考试问题,我想知道原始类型和引用类型是什么?对于数组,我知道引用类型是数组由对象或变量组成的地方,但原始类型是您仅使用 int 或字符串创建数组的地方.(对吗?)

你认为你会如何回答测试中的问题并获得良好的信用?没有真正直接引用原始 ARRAY 类型......有没有办法做到这一点?还是你觉得用数组解释一下就好了.

解决方案

这些是 Java 中的原始类型:

  • 布尔值
  • 字节
  • 简短
  • 字符
  • 内部
  • 浮动
  • 双重

所有其他类型都是引用类型:它们引用对象.

这是Java 语言基础教程的第一部分.>

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?)

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.

解决方案

These are the primitive types in Java:

  • boolean
  • byte
  • short
  • char
  • int
  • long
  • float
  • double

All the other types are reference types: they reference objects.

This is the first part of the Java tutorial about the basics of the language.

这篇关于原始类型和引用类型有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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