Harsha Smith

Ranch Hand
+ Follow
since Jul 18, 2011
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Harsha Smith

is it for those with knowledge of Java(any version) or for absolute beginners in java or for anyone ? What is it inside the book that makes it special or a must read?
6 years ago
only when size is greater than 1 comparision is done between elements. see how it works in treeset class thats present in src.zip in your jdk folder.
is anything being added to logData list?
6 years ago

But doesn't meet client's requirements of matching 2 blank lines, useDelimiter, hasNext()
6 years ago
regex to match blank line is

6 years ago
6 years ago

Threre a lot of good books out there like Java How to Program/Big Java/Head First Java etc. Read the reviews at amazon.com and pick the one that suits your level.
6 years ago
It does throw Class cast exception when more than one object is added to the set.
The method declaration is wrong

You cannot create object of a method

Java is not math. use '==' to check equality of primitives. '=' is an assignment operator. ax should be written as a*x

you cannot invoke methods on primitives.

Please read first few chapters of any good java book and you'll get to know how to fix the problem.

6 years ago
main method "throws Exception" clause wasn't printed,I guess.
declare a variables something like

now keep on calculating the sum while sum less than Math.E. something like this

Add a static method factorial that takes double as argument and returns double. use recursion to get factorial of a number

6 years ago

I perfectly understand as ConcurrentModificationException is thrown when a thread iterating over it AND modifying it.

using enhanced for loop...you are iterating through the collection and by calling poll(), you are modifying it. And yes priority queue is a collection

A is wrong because the overriding method must not throw new or broader checked exceptions.

E is wrong because you are reducing the visibility of the method.

B is correct because FileNotFoundException is the sub class of IO Exception(Narrow Exception)
C is correct because the overriding method may throw a fewer or no exceptions
D is correct because you aren't messing with the visibility of the method
F is correct for obvious reasons.

Additionally 'G' is also correct if exists. something like

G. void think() throws RunTimeException
And no duplicate objects are created if one already exists. saves memory.
6 years ago
As told by others, there is no synchronization. so the following code may help you