Definition of terms.

Instance -- This is where you create a new object or primitive
variable that is based on some class or a primitive. You do this with
the operator new. Example String[] names = new String[20]; This
creates an array capable of holding 20 strings. The array's location
in memory is passed to the variable names. Thus we instantiate an
object.

Initialize. This is where I set the value of a variable to a starting
value. For instance if I had int counter; counter=0; I have created or
instantiated the variable counter and then I initialize it to 0;

Index variable. Any variable that I create to index the locations in
an array. It is what i am doing with the variable that cause me to
call it an index variable.
example
for (int i=0;i<names.length;i++) System.out.println(names[i]);
Here I have used a for loop to repeat the statement System.out.println
(names[i]);
The loop increments the variable i so that it indexes or goes through
all the locations in the array. Each time that it goes through loop
the next string in the array is printed to the screen.

for, while and do while are all ways to repeat the execution of code.
The for loop is designed to let you set up a variable that will
increment or decrement each time you go through the loop.

The while and do while loops can be used to do the same thing, but
they have the ability to set up any number of conditions that will
control the loop. It can be anything from testing to see if you are at
the end of a file that your program is reading, to checking to see if
someone clicked end turn in a game. While and do while loops give you
a very flexible looping system. for loops give you a countable looping
system.

On Jun 21, 9:50 pm, "function(phil)" <[email protected]> wrote:
> Thanks for your reply.
>
> Okay. Let's discuss language. In the paragraph below you us the term
> initialization. What does that mean?
> Does it mean the same as I've heard instantiate a variable and declare
> a variable? Then you use the term "index variable" what does that
> mean? I know what a variable is
> but what do you mean by "index"?
>
> Regarding the while statement. The following code doesn't work as
> planned but it shows my understanding of the
> use of the "while loop". It's a real world example. I think the
> courses should use real world examples. The use of displaying names
> 20 times doesn't make much since to me.
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to