• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cloneable interface and Array  RSS feed

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class Green {
public static void main (String args[]) {
int[] i = null; // 1
Cloneable c = i; // 2
i = (int [])c; // 3
}}

What is the result of attempting to compile and run the program?

source : http://www.danchisholm.net/oct1/guide/chapter3/exam1.html

It is not generating any error as we are working on null. why?
I am not able to understand. Please help in elaborating it.
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has nothing to do with being null.

10.7 Array Members
Every array implements the interfaces Cloneable and java.io.Serializable.
 
Prakash Mahto
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank to all
I got the point
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!