This Java function below is not working as I expected, it's supposed to go through an array of numbers and if it finds a number in the array that is divisible by 2 with a remainder of 0, then it adds it to a new array and returns the new array at the end. Can you help debug the function and explain how why it's not working as expected?

public static List checkForEvens(int [] nums) {
    ArrayList anwer = new ArrayList<Integer>();
    for(int i = 0; i < nums.length; i++) {
    if(nums[i] / 2 == 0) {
    answer.add(nums[i]
     }  
   }
}
system
neeche yah java fnction kaam nahin kar rahaa he jaisaa ki mujhe ummid thi, yah sankhyaon kii ek sarani se guzarana chahie or agar yah us sarani main ek number paata he jo 2 ke saath 2 ke saath vibhajya he, to yah ise ek nae sarani or ritern main jodta heant main nayaa sarani.kya aap fnction ko dibg karne main madad kar sakate hai or samajha sakate hai ki yah apekshit rup se kyon kaam nahin kar rahaa he?

saarvajanik sthitik suchi checkforevens (int [] nums) {
    ArrayList Anwer = nayaa ArrayList <purnank> ();
    for (int i = 0; i <nums.length; i ++) {
    if (nums [i] / 2 == 0) {
    uttar.
     }
   }
}
user
nishchit rup se!fnction 'CheckForevens' ek sarani ke madhyam se punrarit hota he or yadi sarani main koi sankhya 2 se vibhajya he, to yah 'uttar' main joda jaataa he jo baad main waapas aa gaya he.

fnction kaa kaaran apekshit parinaam waapas nahin ho saktaa he, kyonki IF statement, 'IF (NUMS [i] /2 == 0)'.yah kathan un sankhyaon kii talash kar rahaa he jo sarani main 2 se vibhajit ho jaati hai or samaan 0, jo ki aap kya karne kii ummid ke saath sanrekhit nahin karte hai.

iske bajaay, aap modulo oparator kaa upyog ek sankhya ke shesh ke liye jaanchane ke liye karnaa chaahate hai jise 2 se vibhajit kiya ja rahaa he. yadi koi sankhya 2 se vibhajit he or 0 ke shesh ko lautaati he, to ham yah maan sakate hai ki yah ek samaan sankhya he.to, 'if (nums [i] % 2 == 0) ke chote parivartan ko aapke mudde ko hal karnaa chahie.

maine sudhaar ke saath neeche die gaye fnction ko phir se likhaa he.

saarvajanik sthitik suchi checkforevens (int [] nums) {
    ArrayList Anwer = nayaa ArrayList <purnank> ();
    for (int i = 0; i <nums.length; i ++) {
    if (nums [i] % 2 == 0) {
    uttar.
     }
   }
}
assistant
<|system|>
</s>
<|user|>
neeche yah java fnction kaam nahin kar rahaa he jaisaa ki mujhe ummid thi, yah sankhyaon kii ek sarani se guzarana chahie or agar yah us sarani main ek number paata he jo 2 ke saath 2 ke saath vibhajya he, to yah ise ek nae sarani or ritern main jodta heant main nayaa sarani.kya aap fnction ko dibg karne main madad kar sakate hai or samajha sakate hai ki yah apekshit rup se kyon kaam nahin kar rahaa he?

saarvajanik sthitik suchi checkforevens (int [] nums) {
    ArrayList Anwer = nayaa ArrayList <purnank> ();
    for (int i = 0; i <nums.length; i ++) {
    if (nums [i] / 2 == 0) {
    uttar.
     }
   }
}</s>
<|assistant|>
nishchit rup se!fnction 'CheckForevens' ek sarani ke madhyam se punrarit hota he or yadi sarani main koi sankhya 2 se vibhajya he, to yah 'uttar' main joda jaataa he jo baad main waapas aa gaya he.

fnction kaa kaaran apekshit parinaam waapas nahin ho saktaa he, kyonki IF statement, 'IF (NUMS [i] /2 == 0)'.yah kathan un sankhyaon kii talash kar rahaa he jo sarani main 2 se vibhajit ho jaati hai or samaan 0, jo ki aap kya karne kii ummid ke saath sanrekhit nahin karte hai.

iske bajaay, aap modulo oparator kaa upyog ek sankhya ke shesh ke liye jaanchane ke liye karnaa chaahate hai jise 2 se vibhajit kiya ja rahaa he. yadi koi sankhya 2 se vibhajit he or 0 ke shesh ko lautaati he, to ham yah maan sakate hai ki yah ek samaan sankhya he.to, 'if (nums [i] % 2 == 0) ke chote parivartan ko aapke mudde ko hal karnaa chahie.

maine sudhaar ke saath neeche die gaye fnction ko phir se likhaa he.

saarvajanik sthitik suchi checkforevens (int [] nums) {
    ArrayList Anwer = nayaa ArrayList <purnank> ();
    for (int i = 0; i <nums.length; i ++) {
    if (nums [i] % 2 == 0) {
    uttar.
     }
   }
}</s>
