I am Glad to hear you figured it out. I'll see you later for your next problem.
Type: Posts; User: Norm
I am Glad to hear you figured it out. I'll see you later for your next problem.
No the code using the compareTo method. It needs to have a reference to the name in the Person in the Node and a reference to the name in the Person from the user.
No. You need to change a class to add a method to it.
The String class's compareTo method can be used to compare the name variables from two different instances of Node class/Person class. Your...
Does that compile? Does Node have a member named name? The code shows the only members of Node are a Person and a Node.
The == operator tests if the two object references point to the same...
The name is in the Person object and that is inside of a Node object. Something like this:
nodeRef.personRef.name
The user's passed name is in a Person object: public boolean insert(Person...
Yes, not in the Node class. p.name does not exist.
The compiler can not find a declaration for name in the class Node.
Where is the variable name defined? Is it in the Person class object inside of Node?
Note: p is a confusing name for a Node...
An empty method would not contain any processing code. At a minimum it could have a return statement that returned a value of the required type. No return needed for void.
For int: return 0;
for...
Is there any more processing to be done in the method AFTER value is set to false?
If there is nothing more the method should do, it could immediately return false and not execute any more code in...
boolean returnVal = true; // set initial value
// here is some code that does some tests
// if you want to return false, set returnVal = false;
// when exiting the method: return...
Does that mean if the insert tries to add an existing entry, the code should return false?
What is insert supposed to do? Why does it exit if the compare returns not equal?
There could be a...
Look at the documentation for that method in the API doc: https://docs.oracle.com/javase/8/docs/api/index.html
At the top of the page in the blue strip, click on the INDEX link. Then click on the...
This code is trying to compare the contents of two different types of objects: Node and String
int comparison = p.compareTo(name);
I think the description of that code should be: compare...
Do they do what you want them to do? Do you get the correct result?
A suggestion: write a simple short program that calls the compareTo method 3 times:
System.out.println("smaller " +...