Sandeep Mukherji

Ranch Hand
+ Follow
since Mar 23, 2008
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 Sandeep Mukherji

When we call sleep(), it causes the running thread to transit to a ready to run state. Does the sleep() call will also relinquish the lock on the object if it is invoked from a synchronized method?
I am going through the topic TreeSet and Tree Map where I found the following line:

Searching in a HashSet or HashMap can be faster than in a TreeSet or TerrMap, as hashing algorithm usually offer better performance than the search algorithms for balenced tree

My query is "What is a balenced tree?"
12 years ago
Hi friends,

I am also preparing for scjp 1.6. I am rfering Java Certification, by Khlid Mughal. Shoul i follow some other book alongwith this?
Hi,

I am preparing for SCJP 1.6, but have the book Khalid Mughal 1.4, so going through the topics like Collection, Threading, Exception Handeling, Garbage collection of 1.4 currently. I want to know that what topics are added so far(from scjp 1.4) in 1.6 exam and what topics are excluded. Can somebody please help so that i can arrange those topics from somewhere?
Hi Friends,

Generify your List and Map and Set. Change the Iterator to a local variable; it may throw Exceptions if you have it as a field.

Why have you got so much code in the constructor?
Have you come across methods of the Character class which can tell whether a character is a letter, digit, etc? they may be easier for you to use.



Thanks for the suggessions. It helped me to learn a lot.

If you are using f+"walkin.txt" can you add a File to a String? Will that code actually compile?



Yes, it will compile because by doing f+"" we are actually casting the f Object to String.

Will Object1.toString.compareTo(object2) compile? Because the compareTo method of String is parametrised to String it won't accept Object as a parameter.



Yes, it is working. ArrayList al.get(int x) - returns the element Object in the al at the position x. We are storing textFile to the al, which is a String.
The method "public int compareTo(Object o)" Compares this String to another Object. If the Object is a String, this function behaves like compareTo(String). Otherwise, it throws a ClassCastException (as Strings are comparable only to other Strings).
You can refer to http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#compareTo(java.lang.Object). I think, that is the reason it is compiling and generating output successfully (I am not quit sure).
12 years ago
I was going through the Collection Framework and got a line about Vector as:


The Vector class is a legacy class that has been retrofitted to implement the List interface.



If legacy classes refer to the old classes then how can it be retrofitted??
I am confused
12 years ago
Hi Friends,

Worked hard and arrived to the solution as follows. If the code have a scope of more optimization please contribute.


Thanks.
12 years ago
Hi Friends,

Objective: To take a txt file as input and produce an output file which states which word repeated in the file how many times.

Constraints: We can not use String class for that and have to use Collectons only.

My current approach: I took the characters of the file in the ArrayList and tried to create another ArrayList which adds the first arrayList if a blank space is encountered. I planed to take the second ArrayList serch for the occurences of the word by comparing with a HashSet having all the words in it.
Here is the full code:

But I failed Any sugessions please.
12 years ago
I said:


You were using the overrided version of the name in class B


Actually you were hiding the field 'name' in your class B. Pardon me for saying 'Overriding'.
12 years ago
Make a slight change:


You were using the overrided version of the name in class B. You had to take the name of the Class A only.
12 years ago
What are legacy classes?
12 years ago
What is the difference between ArrayList and Vector?
is it only that:
i) Vector is thread- safe and ArrayList is not. and
ii) Vector objects suffer a slight performance panelty due to synchronization.
or something more?
12 years ago
Hi all,

I have copied a code from Khalid A. Mughal on join(), and a bit confused about how the output came. the code is as followed


The output is comming like :

main
23
24
13
21
Thread-0 will join after the completion of other threads
14
22
11
Thread-1 will join after the completion of other threads
12
My concern is, how this output is arrived. Can anyone explain please.