Harsha Smith

Ranch Hand
+ Follow
since Jul 18, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
36
Received in last 30 days
0
Total given
23
Given in last 30 days
0
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?
12 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?
12 years ago


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

12 years ago
12 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.
12 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.

12 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

12 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.
12 years ago
As told by others, there is no synchronization. so the following code may help you


output:
0
2
4
6
8
10
12
14