Skip to content

Sample Code

October 10, 2012

I have been waiting for the 50th post to be special and have been writing it when ever i get some time.

But had a discussion and wanted to post the following code.

My 50th special will come after this 😦

 

import java.util.ArrayList;

public class FinaleTest {

private ArrayList aList = null;

public void addNew(final ArrayList aList) { // what is the significance of this?
aList.add(“Test”);

//aList = new ArrayList(); // what will happen if this line is commented out!

}

public void initArrayList() {
aList = new ArrayList();
aList.add(“Jagan”);
aList.add(“Satya”);
}

public ArrayList getaList() {
return aList;
}

public void setaList(ArrayList aList) {
this.aList = aList;
}

public int getCurrentListCount() {
return aList.size();
}

public static void main(String[] args) {
FinaleTest fTest = new FinaleTest();

fTest.initArrayList();
System.out.println(fTest.getCurrentListCount());
fTest.addNew(fTest.getaList());

System.out.println(fTest.getCurrentListCount());

}

}

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: