Win a copy of Learning Java by Building Android Games this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

resize stack  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need examples of source code that uses resizing method. I was told to look in the Java library or java.util.vector for example source code but I haven't a clue for where to look for that. Any help would be appreciated!
 
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resizing as in GUI painting stuff? Or resizing as in Collections changing size?
Also zZRyanzZz,
I give you full credit for an interesting first name , however it does NOT look very real :roll: , so could you please drop the creative z's?
You can change your display name: here.
 
Ryan William
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to resize an array when the array has reach it's max size.
Thanks.. for the reply Cindy!
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to resize an array when the array has reach it's max size.
The standard solution is to use one of the implementations of the List interface (such as LinkedList and ArrayList). The resizing is automatic, and you get a number of additional bonuses to manipulate your collections and to make your code more reusable.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As above, you may as well use java.util.ArrayList or java.util.Vector to handle automatic resizing.
If you want an example of resizing an array manually, here it is:

System.arraycopy() should always used for speed in cases like these. If you look at the source code for java.util.ArrayList I'm sure you'll find something very similar.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!