| | |
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 |
2dgraphics android api apple applet application arguments array arrays automation banking binary binarytree bluetooth capture chat chatprogramusingobjects class classes client code color component count database derby design eclipse eclipsedevelopment encryption error event exception fractal game givemetehcodez graphics gridlayout gui html ide if_statement image input integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel julia keyword linux list loop macintosh map method methods midlethttpconnection mobile netbeans newbie object os print printing problem producer program programming project projectideas read recursion reference replaysolutions ria scanner screen server set size sms sort sourcelabs sql stop string swing threads transforms tree ui unicode validation windows







