File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Arrays

 
Vidya Ramachandran
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose we have 2 arrays arr1 and arr2 of different lengths, is it possible to say

arr1 = arr2 where arr1.length < arr2.length
 
Paul Clapham
Sheriff
Pie
Posts: 20182
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is a valid assignment. Assuming the arrays are of the same type, that is.
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
 
Vidya Ramachandran
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks paul

can you tell me how it works.. i mean how is it dealt with becoz arr1 is of lesser length that arr2
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can declare an array variable with no size:

String[] tokens;

Now that doesn't point to anything at all yet. But we can make it point to any sized array we like

tokens = arrayOfFive;
tokens = arrayOfTen;

All the tokens variable knows is that it points to an array. The actual array we point to has a size and occupies an amount of memory that depends on the size.

Does that make sense? The ever popular Cup Story over at the campfire is good reading on this kind of thing, too.
 
Vidya Ramachandran
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks stan james
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic