Nakul P. Patel wrote:Hi All,
I want to pass the SCWCD exam.
I wanted to know few things,
1) Is there any difference between the version 1.5 and 6? I meant to say it seems like both the exams covers same topic.
2) I would like to go for lattest version EE 6(IZO 899).Please suggest me a reference book for it.
I am having dilemma about the Head First for servlet and jsp. I love the head first series, but is it enough to read only this book to pass EE 6 ?
Please let me know.
Thanks in advance
Dan Good wrote:Inputs, Outputs, decrements, increments, class string, at Fairfield University. We use the book Java Programming: From Problem Analysis to Program Design. The book is difficult to follow if you know nothing about coding...
Justice Smith wrote:Here I am again. Trying to create this first class (Bank Account), then use it in class (Tester). It tells me it can't recognize variable "balance" when I try to compile class Tester.
I don't know what I'm doing wrong, but it says it can't recognize the variable "balance" in the second set of code.
Steve Luke wrote:The Executor, Callable, and Future are used for three different purposes.
The Callable is the closest thing to Runnable, the biggest difference is that Callable's call() method has a return value while Runnable's run() method returns void. So think of Callable as a task which produces a result, and a Runnable as a task which does not.
The Executor is a container used to run tasks. There are different varieties, and you can build your own, but the idea is you give an Executor a Runnable and it decides when, where, and how to call the run() method. The most common scenario for an Executor is a Thread Pool, which contains and holds a bunch of running Threads and distributes tasks to the Threads to run.
There is a sub-interface of Executor called an ExecutorService, which acts like an Executor but also allows you to submit Callables as well as Runnables. When you submit a task to an ExecutorService you get a Future, which is used to track the progress of the task that was run. It will let you cancel the task, check to see if its is done, or get the results (if the task was a Callable), waiting for it to complete if not done yet.
Souvik Dasgupta wrote:
Download MySQL JDBC driver from the below link:
MySQL JDBC Driver. It is a jar inside a zip folder. Refer the jar file to your application(You can put that jar inside ext/lib also). No need for OJDBC jar. Thats for Oracle DB.
Campbell Ritchie wrote:
I did not intend you to put print statements inside hashCode nor inside equals. If you had run the code I posted, you would have seen that the hash codes were different. And you would have seen, as Steve has explained, that you would look for those pairs in the wrong bucket in your Map.Khushabu Wankhade wrote:i have inserted print statements in hashCode and equals method but its not reachable . . .
You are mistaken saying that the hashCode and equals methods are not reachable. Both are behaving as expected in this instance, and both are reachable. Their overriding behaviour adn polymorphism are correct.
The link I gave you earlier says that the behaviour of a Map is not specified. You cannot predict that you will find the “V” if you have mutable“K”s. You are changing the values used in the equals method, so you cannot expect the Map to behave predictably.
Steve Luke wrote:Your problem is that you are re-using the same instance of dog. In the code in the original post, line 8 you create the dog instance. Then in line 15, you change the name stored in the dog instance to mangolian and in line 16 you try to get it. When you get it from the HashMap, the hashCode for dog is 9 (the length of the string "mangolian"), and there are no dogs in that bin in the HashMap so you get null as a result.
Then in line 17 you change the name stored in the dog instance to "nancy". Note that nancy has the same length as Rover, and so in line 18 when the HashMap goes to look up the dog, it finds an instance in the correct bin. This is the same instance dog that you created in line 8 and whose name you changed in line 17, so when HashMap calls its equals method it compares the value of the names - which will return true because you are using the same instance (the instance you put into the Map as a key to "Rover value" no longer has a name of Rover, it has a name of nancy.) That is why you get the value back in the second case.
Now in the third case, on line 19 you create a new dog instance and give it a name "Rover". This new instance will look into the correct bin, because it has the correct name length, but since the original instance doesn't have the name "Rover" any more (it has "nancy") the equals comparison will be false and you won't get a value returned.
Rule number one for an Object that will be used as a key in a map is to have good hashCode() and equals() implementations. Rule number two is to make it immutable - meaning the values it stores can't be changed. The fields must be private, assigned in the constructor, and only accessible via get() methods (not set() methods). Look up immutable objects for more info on how to do it right.
Khushabu Wankhade wrote:i have inserted print statements in hashCode and equals method but its not reachable
Campbell Ritchie wrote: