Question: Java - Please do not write the code, but answer my simple question that's on the photo. Please do not give advanced suggestions. Keep it

Java - Please do not write the code, but answer my simple question that's on the photo. Please do not give advanced suggestions. Keep it on a beginner level.

Im writing a method find() takes a linked list and a String key and returns an int count of how many times the String key is found.

Java - Please do not write the code, but answer my simple

public class count { public int tofind (String key, Node x) { Node current = x; int count = 0; while( current != null) { if(current.next.equals(key) ) { | count++; My question is that I am tr My question is that I am trying to make a if statement that goes through all the nodes and if key is found then add to the count. But I think that .equals would not work and == doesn't work bc key is a String. So are there any suggestion on what would work for what I am trying to do with this if statement? return count

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 Databases Questions!