Rishi Shah

Ranch Hand
+ Follow
since Sep 05, 2012
Rishi likes ...
Mac Ruby Java
Merit badge: grant badges
For More
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 Rishi Shah

Junilu Lacar wrote:Looks like a good start. I can see this having a following. Are you going to add the various social network buttons to allow sharing? You'll need to do a lot of incremental refinements if/as this site takes off.

This isn't Forrst. :P But yeah, allowing for sharing on various social networks would be a great addon. Also a permalink feature.
10 years ago
No, setting an object to null in order to help garbage collection is just a myth. Like aliens on Earth.
10 years ago

Kathleen Angeles wrote:check samsung website. they have from galaxy mini to the glorious galaxy note.

10 years ago
"Let me integrate my front end with your backend"


On another note, you should probably add a captcha ;)
10 years ago
Implement a custom SecurityManager based on your needs. Even if this were possible with policy files (which it's not), that method would be more inflexible and be more of a hassle.
10 years ago

Martin Vajsar wrote:I still strongly prefer ArrayList over Vector.

Firstly, Collections.synchronizedList(new ArrayList()); does not look like an unreasonable amount of effort to me.

Secondly, when someone spots this construction, it is immediately clear the ArrayList is intentionally synchronized and is therefore going to be used by multiple threads. If I used a Vector instead, the developer to come after me might not know for sure whether I had a bout of nostalgia, or I really use Vector just to get synchronized access.

For me, Vector equals legacy code.

Yeah, I stand corrected. Vectors are pre 1.2 and shouldn't really be used with the newer collections in the Java API.

I wonder why it's not deprecated?

Here is a quote from Jon Skeet explaining (http://stackoverflow.com/a/1386288/603732):

Jon Skeet wrote:
Vector synchronizes on each individual operation. That's almost never what you want to do.

Generally you want to synchronize a whole sequence of operations. Synchronizing individual operations is both less safe (if you iterate over a Vector, for instance, you still need to take out a lock to avoid anyone else changing the collection at the same time) but also slower (why take out a lock repeatedly when once will be enough)?

Of course, it also has the overhead of locking even when you don't need to.

Basically, it's a very flawed approach to synchronization in most situations. As MrSpandex pointed out, you can decorate a collection using the calls such as Collections.synchronizedList - the fact that Vector combines both the "resized array" collection implementation with the "synchronize every operation" bit is another example of poor design; the decoration approach gives cleaner separation of concerns.

As for a Stack equivalent - I'd look at Deque/ArrayDeque to start with.

10 years ago
It means you have another class called 'Product' in your package. Rename your class or delete/rename the other one to fix the issue.
10 years ago

Derik Davenport wrote:

And why can't you package them inside the Jar? Is it due to licensing restrictions?

That sounds promising. How would I go about doing that exactly? Sorry if that sounds extremely noobish. I focused more on the details of how Java worked and less on the details of distribution until just recently.

As I understand it, a Jar file is just a zip file with some extra bits (like a manifest file). These extra bits are used to tell the JVM which class to open up to find Main (among other things). So I would probably have to make up the manifest manually. Then I would need some kind of "archival tool" to create the Java ARchive. Is that all there is to it?

You would pack everything you need inside your Jar file and load the resource as a stream ( http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getResourceAsStream(java.lang.String) ).

If you need the resources as an actual physical file, you could write them to a temporary location after loading them.
10 years ago
Another question is why you even want obtain a primitive int array from your List.
10 years ago
If you pass it through the default TrustManager, it should throw an exception if it is a user-signed certificate and not CA.
10 years ago
Just made this, It's so good!

Ingredients & Recipe (http://sortedfood.com/#!/applestrudel/)

Going to try this next:

Post recipes you've tried that you think are amazing.
10 years ago

Derik Davenport wrote: I can't distribute the JAR by itself, I will be missing the swing and JNA libraries that the application depends on (but which are not part of the JVM).

And why can't you package them inside the Jar? Is it due to licensing restrictions?
10 years ago
Now if only they gave a holiday for this.
10 years ago
What's wrong with just distributing the Jar file?
10 years ago

Darryl Burke wrote:Rishi and chaitanya, both of you might do well to read the API for Class#getConstructors()

Returns an array containing Constructor objects reflecting all the public constructors of the class represented by this Class object.

Yeah, here's the right answer:

10 years ago