简体   繁体   中英

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.

  • use of " new " keyword and
  • 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

These are not keywords: these are JVM bytecode instructions.

Eg Java code new int [3][2] compiles into these bytecodes:

iconst_3
iconst_2
multianewarray [[I 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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