Win a copy of Securing DevOps this week in the Security forum!

Devendra Walanj

+ Follow
since Apr 21, 2010
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 Devendra Walanj

Hello All,

There is one class that performs a calculation and many readers that are waiting to receive the completed calculation. At any given moment many readers may be waiting.
But I want to call the readers with different figures

all I get is the same value in return

Thanks Steve

All i have to do is insert after line 12

Hello all,

I have a thread program where I was testing the thread notify method. But it didn't work
I am not getting the results.
There is one class that performs a calculation and many readers that are waiting to receive the completed calculation. At any given moment many readers may be waiting.
So I am using the notifyall() method to notify all the waiting threads to move to runnable.

But I am not getting the final output and also the total is still prints 0 ( if I replace c.wait() with Thread.sleep(100))

Steve Luke wrote:Lists only accept Objects, and int is not an Object, so it can't go into the List. Because of this the Arrays.asList(T source ...) method misunderstands what you are sending it (it assumes you are using varargs to create a List with 1 Object in it, that Object being an int[]).

You need to use the Integer wrapper Object instead of the primitive int:

Yes you are right. I did thought so but was casting it ..... which also was not right logically.

Thanks for the clearing the issue.
5 years ago
Hello All,

I was trying the list collection.
first i tried by using a string data type. it went smooth.

This code gives me a perfect answers. But when I try the same with Integer datatype it fails.

Fails as in it does not throw an exception, but I thing it stores the array object in the index 0 of the .
It does not make a List of elements as it did with its counter string datatype.

Why is that so ?
5 years ago
Hello I have a code as follows
1. Not working Code :

as you can see fore the the code will not compile

2. Working Code :

As you can see the difference in both the snippets that the placement of the psw object.
So want to know that when I created the PrintWriter object in the try block it's scope got limited it try block only.

Does this mean that object / variables defined in try block have their scope limit to that try block ?
6 years ago

There are special cases, such as casting and "optional methods", but the above is the general idea.

What are these special cases.
Optional Methods ! ... heard for the first time, can you please elaborate ?
6 years ago
Yes the same "Collection that internally uses another Collection then it is used by TreeSet and HashSet"

Me too want to know the use of such collections.
by following code :

the result why a.equals(a1) is false ?
Please explain how equal and instanceof works with classes and objects.
How does equals work at the low level?
Pretty confused in the area.
7 years ago

Greg Charles wrote:If you have trouble with the abstract idea of super classes and sub classes, try to think of it in real world terms. Like I have a Pet, which is a Dog, which is a GreatDane. You have a Pet, which is a Cat, which is a Siamese. Now, I can say you have a pet, or I can say you have a cat. You can say I have a pet, or a dog. I can't say you have a dog, even though it's a pet.

Now let's say that someone else has another kind of Pet, which is just general, no particular species. (The real world example sort of breaks down here, but try to follow along.) We can call it a pet, but we can't call it a dog or a cat, since those are specific kind of pets.

You are essentially doing that in your program. You are saying Hector is a Beta. (And I thought he was a Trojan!) However you are creating a general Beta, and trying to call it a Hector. That's just like calling that guy's Pet a Dog. Some Betas are Hectors, just as some Pets are Dogs, but not all of them.

So what I was doing in

was that trying to downcast the generalised class Beta's reference.

8 years ago

Nicola Garofalo wrote:the mistake is at line 17

You should write

Now you can make the cast (Hector)x

Hey Nicola,

I know that. But I want an explanation that why Casting with class Hector fails.
8 years ago
By following code if I typecast foo's reference f with beta it goes and same with alpha too.
But when I type cast it with Hector it causes ClassCastException. I know about class casting but cannot get that through Hector class.

8 years ago