Author |
Message
|
rajraj |
Posted: Thu Mar 30, 2006 2:17 pm Post subject: why Array starting with Zero , and not with one |
|
|
Novice
Joined: 28 Mar 2006 Posts: 11
|
Hi guys
plz not to take it has a silly query , i faced this question in one of the interview.
why an array starts with zero and not with one.
any suugestions helpful
Thanks is advance. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Mar 30, 2006 2:37 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
In C, arrays start with 0.
In Java, arrays start with 1. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Mar 30, 2006 3:02 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You sure about java ?
I would have thought in java you start your array with 0.
Code: |
for ( int i=0; i< myarray.size(); i++){
// do something
System.out.println(myarray[i]);
} |
In VB I believe you start your array with 1. ?
Haven't touched that stuff in nearly 10 years ...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Mar 30, 2006 3:43 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Oh, wait.
Maybe I meant Scheme.
No, in Scheme arrays start with "car".
Maybe I meant with Perl.
No, in perl, arrays start with $[.
Oh yeah. It's PASCAL that has arrays starting with 1.
I knew it was some language that I've used that was Algol based but not C. I just grabbed the most recent entry from that set, rather than the first entry. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
wschutz |
Posted: Thu Mar 30, 2006 5:19 pm Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
PL/1 arrays start with 1  _________________ -wayne |
|
Back to top |
|
 |
fschofer |
Posted: Thu Mar 30, 2006 11:04 pm Post subject: |
|
|
 Knight
Joined: 02 Jul 2001 Posts: 524 Location: Mainz, Germany
|
|
Back to top |
|
 |
vennela |
Posted: Fri Mar 31, 2006 5:51 pm Post subject: Re: why Array starting with Zero , and not with one |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
rajraj wrote: |
Hi guys
plz not to take it has a silly query , i faced this question in one of the interview |
Tell me why not to take it as silly.
IMHO, whoever interviwed you is not yet ready to interview and gauge somebody's performance. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Mar 31, 2006 6:32 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Vennela - This kind of question is usually not about the actual answer but about how the person responds.
It's like asking someone why it's bad to set DEFPSIST to yes on all queues on a queue manager.
That said, yes, it's not the best question for that sort of thing - unless you're asking it of someone fresh out of school. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
wschutz |
Posted: Fri Mar 31, 2006 7:18 pm Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Quote: |
It's like asking someone why it's bad to set DEFPSIST to yes on all queues on a queue manager.
|
Only a newbie would make such a silly mistake.  _________________ -wayne |
|
Back to top |
|
 |
Vitor |
Posted: Sun Apr 02, 2006 11:44 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
wschutz wrote: |
Quote: |
It's like asking someone why it's bad to set DEFPSIST to yes on all queues on a queue manager.
|
Only a newbie would make such a silly mistake.  |
Yes - but I've been asked a variation of that question in every MQ-related interview I've had.
Go figure...  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|