Mitch Young

Greenhorn
+ Follow
since Dec 15, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mitch Young

Thanks Winston and Jeff.

Just to be clear, if there were more than one class that implemented ResultSet then one would not be able to make this reference: ResultSet rs; ?
Thanks again.
11 years ago
Basic Java interface question:

Why do Java API interfaces have defined methods?
Or is it just defining the contract that the implementing class must follow?

So if I have a reference to the ResultSet interface (i.e. rs) and I call the method rs.next() I am really making an interface reference to the implementing class of the ResultSet interface which has implemented the next() method?

What if there are multiple implementation classes for an interface, if I use an interface reference won't there be a conflict as to which implementing classes method to use?
11 years ago
Thanks Junilu,
I had no idea that this exercise was to create my own implementation of a linked list. I was asked to write this code on a white board in a job interview. Is this a standard interview exercise? In my study of Java I have never come across this exercise. It makes me wonder what other standard exercises I might encounter.
11 years ago
Thanks Campbell and Gaurangkumar for your quick response.


I'm still very confused about what class Node does. Would it be fair to say it is like a Bean? with properties and getters and setters for those properties?

In class Node, does data needs to be some object say a String holding String data that I am searching for? Is next to hold the next element in the list.?

So instead of looping through a LinkedList of say type String or int which are the elements in the list this exercise has a list that contains elements of type Node?

In that case I could loop through the list testing each element(Node) for the value I am looking for then what is the purpose of a Node object holding another Node object.

Thanks again
11 years ago
Hi all,

I am working on this exercise but I don't understand it, Could somebody shed some light on this for me?
Thanks much.

Given the following definition of a node object, traverse a linked
list (given the head of the list and the data you are trying to find)
to determine whether the data is on the list. If the data is stored
in the list, return the node it is stored in, if data is not in the
list return null.

public class Node {
Object data;
Node next;
}

public Node traverseList(Node head, Object data){

}
11 years ago
Thanks m coffee,
That makes sense, I'll do some testing with you solution.
Amit,
Thanks so much, I removed the while loop and it all works as expected now.

I'm not trying to re-register the same user, only check when a user registers if they are already registered and forgot.

I still don't understand why the second time through the loop it was throwing a nullPointerException and a
"SQLEception: Operation not allowed after ResultSet closed" . If it is the end of the ReultSet won' t a call to next() return false and pass control out of the loop? But anyway, it seems that somehow the ResultSet was being closed throwing the nullPointerException.
Thanks again.
Hello Java Ranch-A-Rareos!
I'm querying a mySql db to see if a user that is trying to register is already registered.
I query for the email and use the count function as you can see below: If it returns 0, the user gets registered, if 1, it returns the boolean. What is happening is that if the user is not in the db and the stmt.executeUpdate(insert); executes, when control passes back to the while test if fails because the ResultSet has been closed. Does anybody know how the ResultSet is being closed? Thanks for your help.


Thanks Bear,
That was it, whitespace (Duhh).
12 years ago
JSP
Hi All,
I an having problems comparing the string value of a bean property with another string passed into the jsp as a param using EL and a c:forEach loop.

I have an ArrayList of beans that holds menu items. I'm using a c:forEach to loop through all the beans in the array and only display the ones that have a category property value that matches the param value from the previous page.

<c:forEach var="cm" items="${cacheMenu}" > // ArrayList of MenuBeans

// I have tried all the following :
// cat is the category type like Pizza
<c:if test="${cm.category eq param.cat}">
<c:if test="${cm.category == param.cat}">
<c:if test="${cm.category == 'Pizza'}">
<c:if test="${cm.category == '<%=cat%>'}">
<c:if test="${cm.category eq param.cat}">
<c:if test="${cm[category] eq param.cat}">
<c:if test="${cm['category'] eq param.cat}">
and even more...
<tr>
<td>${cm.category}</td>
<td >${cm.item} <input input="text" size="2" value=""/></td>
<td>${cm.description}</td>
<td>${cm.size}</td>
<td>${cm.price} <input type="hidden"/></td>
</tr>
</c:if>
</c:forEach>

If I use <c:if test="${cm.category != null}.

It prints all the MenuBeans in the list so I know it's the syntax of the if test that's wrong.
Thanks much.">
12 years ago
JSP