| | |
need a sample code for ArrayList
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Just read the API for ArrayList. The methods are quite clear. If you don't understand Collections at all, there is a lot of info here: Java Collections Framework
before you move to the API i guess you need to really get a hold on what an array is, if i may put it in any way an array is just a contiguous memory for similar data types and almost all programming languages support array in java you have to declear an array using the SYNTAX;
datatype [] objectname;
where datatype may be any of the primitve data types or an object,
eg;
int [] x;
String [] name;
the next thing is for you to initilize the size of the array after which these is done with the syntax
objectname= new [integer_value_of size];
eg.
x= new int[10];
name= new String [25];
you can now assing a value to each index in the array
x[0]=34;
x[1]=45;
x[2]=19;
x[3]=49;
x[4]=38;
NOTE :-the index goes from 0 to n-1, n which is the size of the array itself can not be used
datatype [] objectname;
where datatype may be any of the primitve data types or an object,
eg;
int [] x;
String [] name;
the next thing is for you to initilize the size of the array after which these is done with the syntax
objectname= new [integer_value_of size];
eg.
x= new int[10];
name= new String [25];
you can now assing a value to each index in the array
x[0]=34;
x[1]=45;
x[2]=19;
x[3]=49;
x[4]=38;
NOTE :-the index goes from 0 to n-1, n which is the size of the array itself can not be used
if you don't understand the question, don't try to answer. Array != ArrayList as you would have known had you read the documentation (but then, you tell people they shouldn't read the documentation and you clearly have followed your own advise...).
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
![]() |
Similar Threads
- My Sample C++ Code (C++)
- Flash action script sample code and tutorial (Graphics and Multimedia)
- huffman code (C++)
- I Need Sample ASP.NET Code (ASP.NET)
- Something wrong with my code, why Junk character appears? (C)
- anyone has a text-to-braille coding sample? (Java)
- CD Burner code in VC++ (Visual Basic 4 / 5 / 6)
- Linked arraylist (Java)
Other Threads in the Java Forum
- Previous Thread: hi i need coding of this question can any body help me
- Next Thread: password authentication
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary bluetooth character chat class classes client code component consumer csv database desktop draw eclipse error event exception fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javac javaee javaprojects jmf jni jpanel julia linked linux list loop map method methods mobile netbeans newbie objects online oracle oriented panel print printf problem program programming project projects properties recursion replaydirector reporting researchinmotion robot rotatetext rsa scanner screen se server set size sms sort sql string swing template test threads time tree ubuntu update windows







