Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在if条件结束时返回数组列表的对象?_Java_Android_Arraylist_Expandablelistview - Fatal编程技术网

Java 如何在if条件结束时返回数组列表的对象?

Java 如何在if条件结束时返回数组列表的对象?,java,android,arraylist,expandablelistview,Java,Android,Arraylist,Expandablelistview,我有一个数组列表,它需要在最后返回allteams对象,但我不能这样做,当传递null时,它会出现null指针异常,请帮助我解决这个问题。以下是代码示例: private ArrayList<Team> getData() { Intent localIntent = getIntent(); localIntent.getIntExtra("det", 0); if (localIntent.hasExtra("beg")) { Team

我有一个数组列表,它需要在最后返回allteams对象,但我不能这样做,当传递null时,它会出现null指针异常,请帮助我解决这个问题。以下是代码示例:

private ArrayList<Team> getData() {
    Intent localIntent = getIntent();
    localIntent.getIntExtra("det", 0);
    if (localIntent.hasExtra("beg")) {


        Team t1 = new Team("Day 1: Chest, Back, Shoulders, Legs, Biceps, Triceps");
        t1.players.add("Chest – Barbell Bench Press – 4 sets of 8 reps");
        t1.players.add("Back – Lat-pulldowns – 4 sets of 10 reps");
        t1.players.add("Shoulders – Seated Dumbbell Press – 4 sets of 10 reps");
        t1.players.add("Legs – Leg Extensions – 4 sets of 10 reps");
        t1.players.add("Biceps – Barbell Bbicep Curls – 3 sets of 10 reps");
        t1.players.add("Triceps – Triceps Rope Pushdowns – 3 sets of 15 reps");

        Team t2 = new Team("Day 2: Legs, Triceps, Biceps, Chest, Back, Shoulder");
        t2.players.add("Legs – Leg Press Machine – 4 sets of 8 reps");
        t2.players.add("Triceps – Overhead Bar Extensions – 3 sets of 20 reps");
        t2.players.add("Biceps – EZ Bar Curls – 4 sets of 10 reps");
        t2.players.add("Chest – Machine Chest Press – 4 sets of 10 reps");
        t2.players.add("Back – T-Bar Row – 4 sets of 10 reps");
        t2.players.add("Shoulders – Lateral Raises – 3 sets of 20 reps");

        Team t3 = new Team("Day 3: Shoulders, Back, Chest, Legs, Triceps, Biceps");
        t3.players.add("Shoulders – Upright Rows – 3 sets of 15 reps");
        t3.players.add("Back – Close-Grip Pulldowns – 4 sets of 12 reps");
        t3.players.add("Chest – Fly – 4 sets of 10 reps");
        t3.players.add("Legs – Lunges – 3 sets of 10 reps per leg");
        t3.players.add("Triceps – Skullcrushers – 3 sets of 15 reps");
        t3.players.add("Biceps – Hammer Curls – 3 sets of 12 reps");

        ArrayList<Team> allTeams = new ArrayList<Team>();
        allTeams.add(t1);
        allTeams.add(t2);
        allTeams.add(t3);

        return allTeams;


    } else if (localIntent.hasExtra("inter")) {

        Team t1 = new Team("Day 1: Chest, Shoulders and Triceps");
        t1.players.add("Bench Press – 3 sets of 10, 10, 8 (adding weight) reps");
        t1.players.add("Incline Dumbbell Bench Press – 3 sets of 10 reps");
        t1.players.add("Chest Dip – 3 sets of MAX reps");
        t1.players.add("Skullcrushers – 3 sets of 8-10 Reps");
        t1.players.add("One Arm Dumbbell Extension – 3 sets of 10 reps");
        t1.players.add("Tricep Extension – 3 sets of 10 reps");
        t1.players.add("Barbell Front Raise – 4 sets of 12 reps");
        t1.players.add("Dumbbell Lateral Raise – 4 sets of 15, 12, 8, 8 (adding weight) reps");

        Team t2 = new Team("Day 2: Back and Biceps");
        t2.players.add("Wide Grip Pull Up 3 sets of MAX reps");
        t2.players.add("Lat Pull Down – 3 sets of 10 reps");
        t2.players.add("Straight Arm Lat Pull Down – 3 sets of 10 reps");
        t2.players.add("Standing Barbell Curl – 3 sets of 8-10 reps");
        t2.players.add("Preacher Curl – 3 sets of 10 reps");
        t2.players.add("Incline Dumbbell Curl – 3 sets of 10 reps");


        Team t3 = new Team("Day 3: Legs");
        t3.players.add("Squat – 4 sets of 10,10,8,8 reps");
        t3.players.add("Dumbbell Lunge – 3 sets of 8 on each leg");
        t3.players.add("Leg Press – 3 sets of 12 reps");
        t3.players.add("Leg Curl – 3 sets of 15 reps");
        t3.players.add("Leg Extension – 3 sets of 15 reps");
        t3.players.add("Standing Calf Raise – 5 sets of 10,8,8,8,6 (heavy)reps");
        t3.players.add("Seated Calf Raise – 5 sets of 15 (light) reps");

        Team t4 = new Team("Day 4:  Shoulders, chest, and Triceps");
        t4.players.add("Barbell Bench Press – 3 sets of 10, 10, 8 reps");
        t4.players.add("Dumbbell Flys – 3 sets of 10 reps");
        t4.players.add("Cable Crossovers – 3 sets of 10 reps");
        t4.players.add("Close Grip Bench Press – 4 sets of 10, 10, 8, 6 reps");
        t4.players.add("Lying Dumbbell Extension – 3 sets of 10 reps");
        t4.players.add("Tricep Kickback – 3 sets of 10 reps");
        t4.players.add("Seated Dumbbell Press – 4 sets of 10, 10, 8, 8 reps");
        t4.players.add("One Arm Cable Lateral Raise – 3 sets of 12 reps");

        Team t5 = new Team("Day 5: Back and Biceps");
        t5.players.add("Seated Row – 4 sets of 10 reps");
        t5.players.add("Bent Over Barbell Row – 3 sets of 10 reps");
        t5.players.add("Bent Over Row – 3 sets of 12 reps");
        t5.players.add("Smith Machine Upright Row – 3 sets of 8-10 reps");
        t5.players.add("Cable Curl – 4 sets of 8-10 reps");
        t5.players.add("Concentration Curl – 3 sets of 10 reps");
        t5.players.add("Reverse Barbell Curl – 3 sets of 10 reps");

        ArrayList<Team> allTeams = new ArrayList<Team>();
        allTeams.add(t1);
        allTeams.add(t2);
        allTeams.add(t3);
        allTeams.add(t4);
        allTeams.add(t5);

        return allTeams;
    }
    return null;
}
private ArrayList getData(){
Intent localIntent=getIntent();
localIntent.getIntExtra(“det”,0);
if(localIntent.hasExtra(“beg”)){
团队t1=新团队(“第1天:胸部、背部、肩部、腿部、二头肌、三头肌”);
t1.球员。增加(“胸部-杠铃卧推-4组,共8次”);
t1.玩家。添加(“后退–横向下拉–4组10次重复”);
t1.球员。增加(“肩部-坐姿哑铃按压-4组10次”);
t1.玩家。添加(“腿部-腿部伸展-4组10次重复”);
t1.球员。添加(“二头肌-杠铃Bbicep卷发-3套10次”);
t1.球员。添加(“三头肌-三头肌绳索下推-3组15次”);
团队t2=新团队(“第2天:腿部、三头肌、二头肌、胸部、背部、肩部”);
t2.玩家。添加(“腿部-腿部按压机-4套,共8次”);
t2.球员。添加(“三头肌-头顶杆延长-3组,共20次”);
t2.运动员。添加(“二头肌–EZ杆卷发–4组,共10次”);
t2.玩家。添加(“胸部-机器胸部按压-4套10次”);
t2.球员。添加(“背部-T形杆排-4组,共10次”);
t2.运动员。增加(“肩部-侧向抬高-3组,共20次”);
t3组=新团队(“第3天:肩部、背部、胸部、腿部、三头肌、二头肌”);
t3.球员。添加(“肩部-直排-3组,共15次”);
t3.玩家。添加(“背部-紧握下拉-4组,共12次”);
t3.玩家。添加(“胸部-飞行-4套10次”);
t3.运动员。添加(“腿-弓箭步-3组,每组10次”);
t3.玩家。添加(“三头肌-碎头骨-3组,共15次”);
t3.球员。添加(“二头肌-链球-3组,共12次”);
ArrayList allTeams=新的ArrayList();
所有团队。添加(t1);
所有团队。添加(t2);
所有团队。添加(t3);
返回所有团队;
}else if(localIntent.hasExtra(“inter”)){
t1组=新团队(“第1天:胸部、肩部和三头肌”);
t1.球员。增加(“卧推-3套10、10、8(增加重量)重复”);
t1.球员。增加(“倾斜哑铃卧推-3套10次”);
t1.玩家。添加(“胸部下倾–3组最大重复次数”);
t1.玩家。添加(“碎骨机–3套,共8-10次”);
t1.玩家。添加(“单臂哑铃伸展-3套10次”);
t1.运动员。增加(“三头肌伸展-3组10次”);
t1.球员。添加(“杠铃前举-4组,共12次”);
t1.球员。增加(“哑铃横向提升–4组15、12、8、8(增加重量)重复”);
团队t2=新团队(“第2天:背部和二头肌”);
t2.球员。增加(“宽握拉起3组最大重复次数”);
t2.玩家。添加(“横向下拉–3组,共10次”);
t2.玩家。添加(“直臂横向下拉–3组,共10次”);
t2.运动员。添加(“站立杠铃卷曲-3组,共8-10次”);
t2.玩家。添加(“牧师卷发–3套10次”);
t2.运动员。增加(“倾斜哑铃卷曲-3组,共10次”);
t3团队=新团队(“第3天:腿部”);
t3.玩家。添加(“下蹲–4组10,10,8,8次重复”);
t3.运动员。增加(“哑铃弓箭步-每条腿3组,每组8个”);
t3.球员。添加(“腿部按压–3组,共12次”);
t3.球员。添加(“曲腿–3组,共15次”);
t3.球员。添加(“腿部伸展-3组,共15次”);
t3.玩家。添加(“站立小腿抬高-5组10,8,8,6(重)次”);
t3.玩家。添加(“坐式小腿抬高–5组15次(轻)重复”);
t4组=新团队(“第4天:肩部、胸部和三头肌”);
t4.球员。添加(“杠铃板凳压-3套10、10、8次”);
t4.玩家。添加(“哑铃飞-3套10次”);
t4.玩家。添加(“电缆交叉-3套10次重复”);
t4.球员。增加(“紧握式板凳压力机–4套10、10、8、6次重复”);
t4.玩家。添加(“卧式哑铃伸展-3套10次”);
t4.球员。添加(“三头肌回扣–3组,共10次”);
t4.玩家。添加(“坐式哑铃按压-4套,共10、10、8、8次”);
t4.球员。添加(“单臂缆绳横向提升–3组,共12次”);
团队t5=新团队(“第5天:背部和二头肌”);
t5.玩家。添加(“坐着的一排–4组,共10次”);
t5.球员。添加(“俯身杠铃排–3组,共10次”);
t5.玩家。添加(“弯腰行–3组,共12次”);
t5.玩家。添加(“史密斯机器直立排–3组,共8-10次”);
t5.玩家。添加(“电缆卷曲–4套,共8-10次”);
t5.玩家。添加(“集中卷曲-3组10次”);
t5.运动员。添加(“反向杠铃卷曲-3套10次”);
ArrayList allTeams=新的ArrayList();
所有团队。添加(t1);
所有团队。添加(t2);
所有团队。添加(t3);
所有团队。添加(t4);
所有团队。添加(t5);
返回所有团队;
}
返回null;
}

请帮助我解决这个问题我能做些什么来解决这个问题,在结束时它应该返回AllTeam而不是null。

根据这些代码,如果不匹配任何东西,它的返回null对于这些情况添加last else并设置它的默认值。无论它的null是否匹配,它都执行else语句

if()
{
}
else if()
 {
 }
else  {
    Team t1 = new Team("Day 1: Chest, Shoulders and Triceps");
    t1.players.add("Bench Press – 3 sets of 10, 10, 8 (adding weight) reps");
    t1.players.add("Incline Dumbbell Bench Press – 3 sets of 10 reps");
    t1.players.add("Chest Dip – 3 sets of MAX reps");
    t1.players.add("Skullcrushers – 3 sets of 8-10 Reps");
    t1.players.add("One Arm Dumbbell Extension – 3 sets of 10 reps");
    t1.players.add("Tricep Extension – 3 sets of 10 reps");
    t1.players.add("Barbell Front Raise – 4 sets of 12 reps");
    t1.players.add("Dumbbell Lateral Raise – 4 sets of 15, 12, 8, 8 (adding weight) reps");
    ArrayList<Team> allTeams = new ArrayList<Team>();
    allTeams.add(t1);       
    return allTeams;
}
if()
{
}
else if()
{
}
否则{
t1组=新团队(“第1天:胸部、肩部和三头肌”);
t1.球员。增加(“卧推-3套10、10、8(增加重量)重复”);
t1.球员。增加(“倾斜哑铃卧推-3套10次”);
t1.玩家。添加(“胸部下倾–3组最大重复次数”);
t1.玩家。添加(“碎骨机–3套,共8-10次”);
T
private ArrayList<Team> getData() {
   Intent localIntent = getIntent();
   localIntent.getIntExtra("det", 0);
   ArrayList<Team> allTeams = new ArrayList<Team>();

   if (localIntent.hasExtra("beg")) {


    Team t1 = new Team("Day 1: Chest, Back, Shoulders, Legs, Biceps, Triceps");
    t1.players.add("Chest – Barbell Bench Press – 4 sets of 8 reps");
    t1.players.add("Back – Lat-pulldowns – 4 sets of 10 reps");
    t1.players.add("Shoulders – Seated Dumbbell Press – 4 sets of 10 reps");
    t1.players.add("Legs – Leg Extensions – 4 sets of 10 reps");
    t1.players.add("Biceps – Barbell Bbicep Curls – 3 sets of 10 reps");
    t1.players.add("Triceps – Triceps Rope Pushdowns – 3 sets of 15 reps");

    Team t2 = new Team("Day 2: Legs, Triceps, Biceps, Chest, Back, Shoulder");
    t2.players.add("Legs – Leg Press Machine – 4 sets of 8 reps");
    t2.players.add("Triceps – Overhead Bar Extensions – 3 sets of 20 reps");
    t2.players.add("Biceps – EZ Bar Curls – 4 sets of 10 reps");
    t2.players.add("Chest – Machine Chest Press – 4 sets of 10 reps");
    t2.players.add("Back – T-Bar Row – 4 sets of 10 reps");
    t2.players.add("Shoulders – Lateral Raises – 3 sets of 20 reps");

    Team t3 = new Team("Day 3: Shoulders, Back, Chest, Legs, Triceps, Biceps");
    t3.players.add("Shoulders – Upright Rows – 3 sets of 15 reps");
    t3.players.add("Back – Close-Grip Pulldowns – 4 sets of 12 reps");
    t3.players.add("Chest – Fly – 4 sets of 10 reps");
    t3.players.add("Legs – Lunges – 3 sets of 10 reps per leg");
    t3.players.add("Triceps – Skullcrushers – 3 sets of 15 reps");
    t3.players.add("Biceps – Hammer Curls – 3 sets of 12 reps");

    allTeams.add(t1);
    allTeams.add(t2);
    allTeams.add(t3);

    return allTeams;


} else if (localIntent.hasExtra("inter")) {

    Team t1 = new Team("Day 1: Chest, Shoulders and Triceps");
    t1.players.add("Bench Press – 3 sets of 10, 10, 8 (adding weight) reps");
    t1.players.add("Incline Dumbbell Bench Press – 3 sets of 10 reps");
    t1.players.add("Chest Dip – 3 sets of MAX reps");
    t1.players.add("Skullcrushers – 3 sets of 8-10 Reps");
    t1.players.add("One Arm Dumbbell Extension – 3 sets of 10 reps");
    t1.players.add("Tricep Extension – 3 sets of 10 reps");
    t1.players.add("Barbell Front Raise – 4 sets of 12 reps");
    t1.players.add("Dumbbell Lateral Raise – 4 sets of 15, 12, 8, 8 (adding weight) reps");

    Team t2 = new Team("Day 2: Back and Biceps");
    t2.players.add("Wide Grip Pull Up 3 sets of MAX reps");
    t2.players.add("Lat Pull Down – 3 sets of 10 reps");
    t2.players.add("Straight Arm Lat Pull Down – 3 sets of 10 reps");
    t2.players.add("Standing Barbell Curl – 3 sets of 8-10 reps");
    t2.players.add("Preacher Curl – 3 sets of 10 reps");
    t2.players.add("Incline Dumbbell Curl – 3 sets of 10 reps");


    Team t3 = new Team("Day 3: Legs");
    t3.players.add("Squat – 4 sets of 10,10,8,8 reps");
    t3.players.add("Dumbbell Lunge – 3 sets of 8 on each leg");
    t3.players.add("Leg Press – 3 sets of 12 reps");
    t3.players.add("Leg Curl – 3 sets of 15 reps");
    t3.players.add("Leg Extension – 3 sets of 15 reps");
    t3.players.add("Standing Calf Raise – 5 sets of 10,8,8,8,6 (heavy)reps");
    t3.players.add("Seated Calf Raise – 5 sets of 15 (light) reps");

    Team t4 = new Team("Day 4:  Shoulders, chest, and Triceps");
    t4.players.add("Barbell Bench Press – 3 sets of 10, 10, 8 reps");
    t4.players.add("Dumbbell Flys – 3 sets of 10 reps");
    t4.players.add("Cable Crossovers – 3 sets of 10 reps");
    t4.players.add("Close Grip Bench Press – 4 sets of 10, 10, 8, 6 reps");
    t4.players.add("Lying Dumbbell Extension – 3 sets of 10 reps");
    t4.players.add("Tricep Kickback – 3 sets of 10 reps");
    t4.players.add("Seated Dumbbell Press – 4 sets of 10, 10, 8, 8 reps");
    t4.players.add("One Arm Cable Lateral Raise – 3 sets of 12 reps");

    Team t5 = new Team("Day 5: Back and Biceps");
    t5.players.add("Seated Row – 4 sets of 10 reps");
    t5.players.add("Bent Over Barbell Row – 3 sets of 10 reps");
    t5.players.add("Bent Over Row – 3 sets of 12 reps");
    t5.players.add("Smith Machine Upright Row – 3 sets of 8-10 reps");
    t5.players.add("Cable Curl – 4 sets of 8-10 reps");
    t5.players.add("Concentration Curl – 3 sets of 10 reps");
    t5.players.add("Reverse Barbell Curl – 3 sets of 10 reps");

    allTeams.add(t1);
    allTeams.add(t2);
    allTeams.add(t3);
    allTeams.add(t4);
    allTeams.add(t5);

    return allTeams;
    }
  return allTeams;
}
private ArrayList<Team> getData() {
Intent localIntent = getIntent();
localIntent.getIntExtra("det", 0);
ArrayList<Team> allTeams = new ArrayList<Team>();
if (localIntent.hasExtra("beg")) {


    Team t1 = new Team("Day 1: Chest, Back, Shoulders, Legs, Biceps, Triceps");
    t1.players.add("Chest – Barbell Bench Press – 4 sets of 8 reps");
    t1.players.add("Back – Lat-pulldowns – 4 sets of 10 reps");
    t1.players.add("Shoulders – Seated Dumbbell Press – 4 sets of 10 reps");
    t1.players.add("Legs – Leg Extensions – 4 sets of 10 reps");
    t1.players.add("Biceps – Barbell Bbicep Curls – 3 sets of 10 reps");
    t1.players.add("Triceps – Triceps Rope Pushdowns – 3 sets of 15 reps");

    Team t2 = new Team("Day 2: Legs, Triceps, Biceps, Chest, Back, Shoulder");
    t2.players.add("Legs – Leg Press Machine – 4 sets of 8 reps");
    t2.players.add("Triceps – Overhead Bar Extensions – 3 sets of 20 reps");
    t2.players.add("Biceps – EZ Bar Curls – 4 sets of 10 reps");
    t2.players.add("Chest – Machine Chest Press – 4 sets of 10 reps");
    t2.players.add("Back – T-Bar Row – 4 sets of 10 reps");
    t2.players.add("Shoulders – Lateral Raises – 3 sets of 20 reps");

    Team t3 = new Team("Day 3: Shoulders, Back, Chest, Legs, Triceps, Biceps");
    t3.players.add("Shoulders – Upright Rows – 3 sets of 15 reps");
    t3.players.add("Back – Close-Grip Pulldowns – 4 sets of 12 reps");
    t3.players.add("Chest – Fly – 4 sets of 10 reps");
    t3.players.add("Legs – Lunges – 3 sets of 10 reps per leg");
    t3.players.add("Triceps – Skullcrushers – 3 sets of 15 reps");
    t3.players.add("Biceps – Hammer Curls – 3 sets of 12 reps");

    allTeams.add(t1);
    allTeams.add(t2);
    allTeams.add(t3);


} else if (localIntent.hasExtra("inter")) {

    Team t1 = new Team("Day 1: Chest, Shoulders and Triceps");
    t1.players.add("Bench Press – 3 sets of 10, 10, 8 (adding weight) reps");
    t1.players.add("Incline Dumbbell Bench Press – 3 sets of 10 reps");
    t1.players.add("Chest Dip – 3 sets of MAX reps");
    t1.players.add("Skullcrushers – 3 sets of 8-10 Reps");
    t1.players.add("One Arm Dumbbell Extension – 3 sets of 10 reps");
    t1.players.add("Tricep Extension – 3 sets of 10 reps");
    t1.players.add("Barbell Front Raise – 4 sets of 12 reps");
    t1.players.add("Dumbbell Lateral Raise – 4 sets of 15, 12, 8, 8 (adding weight) reps");

    Team t2 = new Team("Day 2: Back and Biceps");
    t2.players.add("Wide Grip Pull Up 3 sets of MAX reps");
    t2.players.add("Lat Pull Down – 3 sets of 10 reps");
    t2.players.add("Straight Arm Lat Pull Down – 3 sets of 10 reps");
    t2.players.add("Standing Barbell Curl – 3 sets of 8-10 reps");
    t2.players.add("Preacher Curl – 3 sets of 10 reps");
    t2.players.add("Incline Dumbbell Curl – 3 sets of 10 reps");


    Team t3 = new Team("Day 3: Legs");
    t3.players.add("Squat – 4 sets of 10,10,8,8 reps");
    t3.players.add("Dumbbell Lunge – 3 sets of 8 on each leg");
    t3.players.add("Leg Press – 3 sets of 12 reps");
    t3.players.add("Leg Curl – 3 sets of 15 reps");
    t3.players.add("Leg Extension – 3 sets of 15 reps");
    t3.players.add("Standing Calf Raise – 5 sets of 10,8,8,8,6 (heavy)reps");
    t3.players.add("Seated Calf Raise – 5 sets of 15 (light) reps");

    Team t4 = new Team("Day 4:  Shoulders, chest, and Triceps");
    t4.players.add("Barbell Bench Press – 3 sets of 10, 10, 8 reps");
    t4.players.add("Dumbbell Flys – 3 sets of 10 reps");
    t4.players.add("Cable Crossovers – 3 sets of 10 reps");
    t4.players.add("Close Grip Bench Press – 4 sets of 10, 10, 8, 6 reps");
    t4.players.add("Lying Dumbbell Extension – 3 sets of 10 reps");
    t4.players.add("Tricep Kickback – 3 sets of 10 reps");
    t4.players.add("Seated Dumbbell Press – 4 sets of 10, 10, 8, 8 reps");
    t4.players.add("One Arm Cable Lateral Raise – 3 sets of 12 reps");

    Team t5 = new Team("Day 5: Back and Biceps");
    t5.players.add("Seated Row – 4 sets of 10 reps");
    t5.players.add("Bent Over Barbell Row – 3 sets of 10 reps");
    t5.players.add("Bent Over Row – 3 sets of 12 reps");
    t5.players.add("Smith Machine Upright Row – 3 sets of 8-10 reps");
    t5.players.add("Cable Curl – 4 sets of 8-10 reps");
    t5.players.add("Concentration Curl – 3 sets of 10 reps");
    t5.players.add("Reverse Barbell Curl – 3 sets of 10 reps");

    allTeams.add(t1);
    allTeams.add(t2);
    allTeams.add(t3);
    allTeams.add(t4);
    allTeams.add(t5);

}
return allTeams;
}
ArrayList teamList = getData()
if(teamList.isNotEmpty()){
*do your stuff with teamList here*
}