Question: Write a method called findTerm ( ) in java that takes a string term and a string ArrayList as parameters. If the term exists inside

Write a method called findTerm() in java that takes a string term and a string ArrayList as parameters.
If the term exists inside the ArrayList, then a boolean value of true is returned.
Else the term does not exist, false is returned. Note that capitalization matters.
For example, "cat"and "Cat" are not considered the same term.
Existing Code:
import java.util.*;
public class Exercise3{
//add code below this line
//add code above this line
public static void main(String args[]){
String x = args[0];
ArrayList y = new ArrayList();
for (int i =1; i < args.length; i++){
y.add(args[i]);
}
System.out.println(findTerm(x, y));
}
}
Hint
The main() method's job is to take the first command and turn it into a boolean x.
Then take the second command and every command after and turn those into integers.
These integers are then added to an ArrayList y.
Your task is to check whether the boolean is true or false and print only the relevant integers within the ArrayList that correspond to true or false.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!