File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple question--

 
Abdul Mohsin
Ranch Hand
Posts: 111
Java Linux Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

why its not possible to assign byte array to int array while in the case of objects its possible.

int[] arrNew;
byte[] arrByte={1,2,3};
int[] arrInt={1,2,3};

arrNew=arrByte; /// not allowed

Regards,

Abdul Mohsin
 
Sanjay Singh
Ranch Hand
Posts: 37
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why its not possible to assign byte array to int array while in the case of objects its possible.


Reason: The Array of primitive can't be cast to an array of a different primitive type. While in the case of object it is possible cause array itself is Object, so we can assign an array to Object. e.g.

this code is fine-
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic