Look, java is very strong on types. It was hard for me at first to accept why. I think you know variables by now. Arrays hold a group of variables of the same type. An array is fixed length -- you cannot add to it after you define how long it is. So, let's do an array of type Integer==========
int [] myNumbers = new Array(5);
myNumbers[0] = 2;
myNumbers[1] = 12;
myNumbers[2] = 5;
myNumbers[3] = 99;
myNumbers[4] = 100;
the variable is "myNumbers"
java sees it is an array because of "[]"
java wants variables of type Integer because of "int"
java constructed the array with 5 slots
the first slot is a special number we call an index "0"
index "4" is the last slot
there are five slots, but the index (special number) always begins with "0", not "1"
====
I loaded the array, one slot at a time
Now, I can call the third slot with a variable --
int x = myNumbers[2]
=========================
I took the time to make the example to explain the next harder step -- Objects
I want you to think of Objects as nothing more than a fancy Array. Instead of the special number "index" we can use a name like "wheels" and instead of only having one type of number, Object can have any type.
class Car {
int wheels;
Color colors;
float speed;
}
=========
Car myCar = new Car();
myCar.wheels = 4;
myCar.colors = Color.red;
myCar.speed = 45.6f;
===============
Go to your public library and get a book "Teach Yourself Java in 21 Days". Read that one and others until you get the ABCs down on java. Then, go back to the sun.com and use their documentation. It's good but very concise.
p.s. I love java. it's fast enough. and it lets me rig just about anything for testing.
2006-10-29 01:38:08
·
answer #1
·
answered by Anonymous
·
0⤊
0⤋
It is a data structure that stores values. It has a fixed number of indices.
In Java you can declare an array like this:
int[] myArray = new int[n]
And you can replace the int with any type of object. 'n' is a variable that tells you how big the array will be. And it is indexed from 0 to (n-1). An important feature of arrays is the length function, which is used when you want to loop through the array. myArray.length, notice how there are no parenthesis on the length, this is special to the array in java. Hope this helps.
2006-10-29 02:46:41
·
answer #2
·
answered by Anonymous
·
0⤊
0⤋
An array in java is the same thing as an array in C, C++, Assembler, COBOL, Basic, Fortran, etc.
In computer programming, a group of homogeneous elements of a specific data type is known as an array.
http://en.wikipedia.org/wiki/Array
http://www.programmingtutorials.com/java.aspx
2006-10-29 01:20:30
·
answer #3
·
answered by Anonymous
·
0⤊
0⤋
Re:... the minimum and maximum numbers. You need two holding (storage) areas. (Variables.) One to hold the min value and one to hold the max value. When your program starts, initialize the min value with something like 9999999. Then, as the program reads each of the ten numbers, take a moment and compare that number to the current number in the min variable and that number to the current number in the max variable. If this current number read is LESS than the current min value, then THAT number becomes the NEW min variable. Move it in there. It will the first time thru. Recall we started it out with 9999999, so of course it will be lower. If this current number read is GREAT than the current max value, then THAT number becomes the NEW min variable. Move it in there. It will the first time thru. It will begin as 0. That's it. When all ten numbers are looked at and compared in this way, your min variable will contain the lowest number entered, and your max variable will contain the largest value entered.
2016-05-22 05:04:13
·
answer #4
·
answered by Susan 4
·
0⤊
0⤋
Array is a collection of values that have same dataTypes that you can give the size of array.
Array is zero-based indexing.
For exmaple:
int[] myArr=new int[10]
myArr>>>Name of the array.
dataType>>>int.
And it can get 10 elements.
also you can acccess or insert values like below:
myArr[0]=123;
.
.
.
Array in JAVA is like array in other languages.
2006-10-30 04:41:28
·
answer #5
·
answered by Moein 3
·
0⤊
0⤋
an array is a standard programming construct that you find in most programming languages - it is a way of grouping data together
Imagine a row of empty shoeboxes with an elastic band holding them all together - that is an array - you can put alomost anything you like in them - imagine putting the names of salesment on the boxes - one per box, now you can sort them, reference them (or what ever)
2006-10-29 01:15:08
·
answer #6
·
answered by cool_clearwater 6
·
0⤊
0⤋
array is a kind of data structure that can hold anything depends on the datatype. for instance, if you create a string array, then you can hold a number of strings in that array. if you create an int array, you can store a number of int in that array. HOWEVER, if you have an object array, you can store any objects in that array.
2006-10-29 01:47:52
·
answer #7
·
answered by themadman 2
·
0⤊
0⤋
an array is like a "database" or call it a table, folder, anything..that accepts entries.
Example:
Array-->Cars
entities--> BMW, Honda, Ford...
I personally got so much help from www.w3schools.com
2006-10-29 01:13:44
·
answer #8
·
answered by Anonymous
·
0⤊
0⤋
This is the web page you should be starting at.
You can also download this tutorial to study at your leisure.
Have fun.
2006-10-29 01:28:30
·
answer #9
·
answered by AnalProgrammer 7
·
0⤊
0⤋