Java

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentJava

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old November 15th, 2006, 04:14 PM
jimmy_24 jimmy_24 is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Posts: 1 jimmy_24 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
how to insert an element into a sorted array (Java)

I am having difficulty with a question in an assignment.

in the class, we are managing booklists objects. which are essentially arrays that hold book objects (book class is given to us).

we are supposed to write an insert() class where i need to insert a reference to a book object into the array, and i already have a method which compares the book to the others and gives me a positive, 0, or negative number if the book is after, in the position, or before the book it is being compared to respectively.
(and the list is already sorted alphabetically so i don't need to do sort it).

the problem i have is actually inserting the book in the required position and "pushing" all the other books forward one space in the array.
the other problem is that once the array is full i need to transfer everything to a bigger array - twice it's size..

and of course - we're ment to do this without using arrayList, but normal arrays.
also - this is an introductory course so we're not really ment to use anything we haven't learned so far. we covered the for, while, do-while loops and general conditional statements and arrays. and we're not allowed to use any array methods.
any help with this will be GREATLY apreciated.

i wrote a single line and don't know where to go from there.
i'm completely new in programming

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentJava > how to insert an element into a sorted array (Java)


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap