You are not logged in.
Pages: 1
Hi I need to learn java language "Arrays"
from zero, cause I don't know how to use arrays I'mm fully not understaing this topic in java
Wisdom is a tree which grows in the heart and fruits on the tongue
Offline
they are quite simple actually, in my opinion at least.
int x = 1; // regular integer
int[] y; // an integer array! it is still just an empty name...
y = new int[5]; // we put a fresh array length of length 5 to it. think of box with exactly 5 slots for ints.
y[0] = 11; // we can access the 5 slots with "index". indexes start from zero. (so 0,1,2,3 and 4 are valid).
y = new int[99]; // we erase the current array and create new one, as size cannot change in-between.
for(int i=0; i<y.length; i++){ y[i] = i+1; } // we put numbers 1-99 to the array.
try{ y[100] = 0; } // watch here, we access 101th slot in the array, which does not exist.
catch(IndexOutOfBoundsException){} // an error will be raised. be careful with this.
string[] z; // string array is as fine as any other...
myObject[] mo; // any obeject can form an array!
bool[,] b = new bool[10,10] // a fancy, two-dimensional array! it works like other arrays, but you must give two indexes to access "a slot".
bool[,,,] bbb = new bool[2,4,6,8]; // while this is legit, it may use lots of space.
int[][] ii = new int[5][]; // an array of array of ints! box, which contains boxes, which contain ints.
ii[0] = new int[4] // a new box to a box.
ii[0][0] // a number to box inside box.
arrays have also many useful built-in methods which you can search from the manual.
You will die knowing being right. My only cost is your fullfilment.
--- The Devil
Offline
Why don't you take the help any online tutorial for programming?
Offline
There are many ways to learn JAVA as it is most widely used and still leading the market but as to learn JAVA, you should always consider a knowledge source which takes care of your clarity of concepts and also provides you a career path which will follow once you become the master in the language(here, it is JAVA).
Now, JAVA is not an easy thing to learn, but with constant dedication and proper guidelines, one can master it.
There are also online tutorial available to learn Java programming.
Hope it will help!!!
Offline
Pages: 1