简体   繁体   English

java中创建对象的不同方式

[英]Different ways to create objects in java

I know this is very basic question but please read the full question first.我知道这是非常基本的问题,但请先阅读完整的问题。 Its bit confusing for me so I need all your help.这让我有点困惑,所以我需要你的帮助。 We know that there are two ways of creating an object in java.我们知道在java中有两种创建对象的方式。

  • use of " new " keyword and使用“ new ”关键字和
  • class.forName() . class.forName()

But I came across some other ways also in a book to create an object which I am not able to understand.但是我在一本书中也遇到了一些其他方法来创建一个我无法理解的对象。 The keywords are关键词是

  • newarray新数组
  • anewarray新阵列
  • multianewarray多新阵列

I am not getting any good study meterial on internet for these keywords.对于这些关键字,我在互联网上没有得到任何好的学习资料。 Please help me out.请帮帮我。 I am posting the link here.我在这里发布链接。 Please read the first 2 lines.请阅读前两行。 http://www.artima.com/insidejvm/ed2/gcP.html http://www.artima.com/insidejvm/ed2/gcP.html

These are not keywords: these are JVM bytecode instructions.这些不是关键字:这些是 JVM 字节码指令。

Eg Java code new int [3][2] compiles into these bytecodes:例如 Java 代码new int [3][2]编译成这些字节码:

iconst_3
iconst_2
multianewarray [[I 2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM