Sanat Pandey Sanat Pandey - 2 years ago 414
Android Question

Using Getter and Setter for arraylist in java

I have a problem that I want to set and get an

from setter and getter methods of android. But I am new to android and Java and don't know how to do that? Can anyone help me regarding this problem?

Answer Source

Example -

import java.util.ArrayList;
import java.util.List;

public class Test {

List<String> list = null;

public List<String> getList() {
    return list;

public void setList(List<String> list) {
    this.list = list;

public static void main(String[] args) {
    Test test = new Test();
    List<String> sample = new ArrayList<String>();
    sample.add("element 1");
    List<String> sample1 = test.getList();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download