Become a part of the TranceAddict community!Frequently Asked Questions - Please read this if you haven'tSearch the forums
TranceAddict Forums > Main Forums > Chill Out Room > Java programing
  Last Thread   Next Thread
Share
Author
Thread    Post A Reply
PHALPAX
Supreme tranceaddict



Registered: Dec 2003
Location: Boston
Java programing

I'm in the middle of a java code quiz and was wondering if anyone knows whats an "off-by-one" error when using arrays.

Old Post Jan-15-2004 17:46  United States
Click Here to See the Profile for PHALPAX Click here to Send PHALPAX a Private Message Add PHALPAX to your buddy list Report this Post Reply w/Quote Edit/Delete Message
whiskers
old skool



Registered: Sep 2001
Location: in your dreams

i'm taking a wild guess - your program is going beyond the size of an array, thinking it's 1 unit bigger than it really is.


yep, http://www.cs.ucl.ac.uk/staff/t.pag...javaErrors.html


p.s. you sneaky bastard


___________________

Old Post Jan-15-2004 17:53  Ukraine
Click Here to See the Profile for whiskers Click here to Send whiskers a Private Message Add whiskers to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Fundamental
Still Alive in '25



Registered: Apr 2001
Location: Scotland

Hmmm... If you exceed the set length of an array in Java you should be getting a 'NullPointerException'.


___________________

"I expect to pass through life but once. If therefore, there be any kindness I can show, or any good thing I can do to any fellow being, let me do it now, and not defer or neglect it, as I shall not pass this way again."

Old Post Jan-15-2004 18:07  Scotland
Click Here to See the Profile for Fundamental Click here to Send Fundamental a Private Message Add Fundamental to your buddy list Report this Post Reply w/Quote Edit/Delete Message
PHALPAX
Supreme tranceaddict



Registered: Dec 2003
Location: Boston

quote:
Originally posted by whiskers
i'm taking a wild guess - your program is going beyond the size of an array, thinking it's 1 unit bigger than it really is.


yep, http://www.cs.ucl.ac.uk/staff/t.pag...javaErrors.html


p.s. you sneaky bastard


ahahaha thanks whiskers

Old Post Jan-15-2004 18:08  United States
Click Here to See the Profile for PHALPAX Click here to Send PHALPAX a Private Message Add PHALPAX to your buddy list Report this Post Reply w/Quote Edit/Delete Message
cviper
Lurking on TA



Registered: Sep 2001
Location: NGC-6543 TekniskFysik - levande lik!

quote:
Originally posted by whiskers
i'm taking a wild guess - your program is going beyond the size of an array, thinking it's 1 unit bigger than it really is.


Yeah, java starts counting at 0 when indexing arrays, which also means that the last element is (size-1).

It's another thing java got from C/C++: in C a[i] is equivalent to *(a+i). 'a' decays to a pointer which points to the first element in the array (i.e. the first element is *(a+0) or a[0]).


___________________
The fears of the past are the dreams of the future

Old Post Jan-15-2004 18:12  Sweden
Click Here to See the Profile for cviper Click here to Send cviper a Private Message Add cviper to your buddy list Report this Post Reply w/Quote Edit/Delete Message
PHALPAX
Supreme tranceaddict



Registered: Dec 2003
Location: Boston

quote:
Originally posted by Fundamental
Hmmm... If you exceed the set length of an array in Java you should be getting a 'NullPointerException'.



Yeah the nullexception would work, but the question i was asked was asking the about anatomy of an off-by-one error.




And they are not letting me use a compiler!

Old Post Jan-15-2004 18:13  United States
Click Here to See the Profile for PHALPAX Click here to Send PHALPAX a Private Message Add PHALPAX to your buddy list Report this Post Reply w/Quote Edit/Delete Message

TranceAddict Forums > Main Forums > Chill Out Room > Java programing
Post New Thread    Post A Reply

 
Last Thread   Next Thread
Click here to listen to the sample!Pause playback[1969] []

Click here to listen to the sample!Pause playback[1969]

Show Printable Version | Subscribe to this Thread
Forum Jump:

All times are GMT. The time now is 06:02.

Forum Rules:
You may not post new threads
You may not post replies
You may not edit your posts
HTML code is ON
vB code is ON
[IMG] code is ON
 
Search this Thread:

 
Contact Us - return to tranceaddict

Powered by: Trance Music & vBulletin Forums
Copyright ©2000-2026, Jelsoft Enterprises Ltd.
Privacy Statement / DMCA
Support TA!