Henry Wong

+ Follow
since Sep 28, 2004
Henry likes ...
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
New York City
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
(keep public parts private until JForum day)
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Henry Wong

Alyxandra Harp wrote:From my understanding of null, it means the variable has no value. It is not any number, not even 0.

A null value is for reference variables only. If a reference variable has a value of null, it means that it is not referring to any object/instance.  Internally, of course, null has a value -- everything with a state (ie. including pointing to nothing) has a value...

4 days ago

Den Yankov wrote:I have timeout exception.Please help me understand what wrong, in my java code implementation.

A timeout is exactly that -- something in your network setup (and configuration) isn't responding in time. You need to figure out exactly what is being timed out, and then, you need to figure out why. This is dependent on your setup, and debugging it ... and can't really be done via looking at code.


Daniel Demesmaecker wrote:Nevermind after reading some additional posts? I supose ranchforeman is below rancher?

IMHO, it is actually debatable if Ranch Foreman is below or above Rancher...

I think of it as this. The Ranch Foreman and Master Rancher titles are automatic boosts to the Ranch Hand and Rancher titles respectively. As such, they are temporary, and hence, does not add privileges.  A better way to think about it may be ... The Ranch Foreman title is a sign of a great Ranchhand, and an indication that, in the future, is a candidate for a promotion to Rancher or Bartender.

5 days ago

There is a world of difference between "what is signing?" to "how to setup web services for glassfish?". Furthermore, security is a layer on top of that. Additionally, Web Services and Servlets are not the same thing, so there is confusion in your question as well...

Perhaps starting with the glassfish tutorials would be a good idea?


Bax Fos wrote:
So where is the use of signing a key, especially self-signing a key and what is exaclty done when a key got signed?

Long story short. Signing a certificate basically means encrypting it with your private key. Since it can be decrypted (with a public key), it is not secure obviously. However, it does prove that you encrypted (signed) it, as you are the only one holding the private key (and is capable of doing it).


saurabhmehta mehta wrote:
There are 2 threads in the program, the new thread executes statements inside the run method whereas the main thread runs inside the main method, is my understanding correct? From the output it seems the main thread after the line " executor.awaitTermination(5, TimeUnit.SECONDS);" skipped the finally block and directly executed the statements outside it. Then it came back inside the finally method. All this is done by the main thread.Is this a normal flow for a single thread?

How did you draw that conclusion? That line doesn't have any output.  And also, how do you know the main thread "executed statements out of it"? Heck, what does that even mean? 

Are you referring to the "running task" output? This output is printed by the other thread -- not the main thread.


saurabhmehta mehta wrote:
Yes I can see that, but after exiting the try block the control first goes to the statements outside the finally block and then to the statements inside the finally are executed. Is that the normal execution flow. Please help if I am missing something..

Keep in mind that you have more than one thread here. You need to follow the flow of each thread independently.

Also, you seem to be mixing standard out with standard error, so, it is possible for you messages to be out of order too.


saurabhmehta mehta wrote:
According to the output it seems finally was not executed despite the try block getting completed. Am I right with the understanding? And why was the exception immediately thrown before going to the finally block?

Not sure how you draw that conclusion since there are messages in the output that can only be produced by the finally block...


Also, one of the techniques used during an interview, is to be rude, in order to see how the candidate behaves.  Personally, I think that it is a stupid technique, that it doesn't really work at finding a good candidate, that Google made famous (or more correctly, infamous).

Regardless, getting into an argument is probably *not* the correct answer -- regardless of how bad the technique is.

1 week ago

S Fox wrote:The reason it needs to be generic is because map should be any kind of a map, usually String or Char for key, and integer or double for value.
That's why I wrote it as Map<T, Number> in the method, maybe this is wrong?

Unfortunately, the IS-A rules applies differently with generics. Yes, a Double IS-A Number. However, a Map<Character, Double> is *not* IS-A Map<Character, Number>. This is what wildcards are used for -- which also limits on what can be done.

1 week ago

The term "virtual function" comes from C++. With it, functions support polymorphism, meaning it doesn't matter what pointer type is used, as it will always called the method of the subclass (based on the actual object type, and not the pointer type).

With Java, this control isn't available. Static and private methods are never polymorphic. And the rest are always polymorphic.


First, a big thanks to Bryson Payne for being here to promote the book Learn Java the Easy Way: A Hands-On Introduction to Programming.

The winners are:

    Steven Ackerman
    Paul Clapham
    Mark Andrew Davis
    tony narloch

Please send your snail mail address to bookpromotion AT javaranch DOT com. To ensure the quickest response, please provide the following:

Your name (first and last - if your CodeRanch name is different, please include both your real name and Ranch name)
Country (needed even if requesting an e-book)
Phone Number

Also, please include the following as the subject of your Email.

Book Promo Winner - Learn Java the Easy Way: A Hands-On Introduction to Programming - Tuesday, December 5th, 2017

Image from unknown

As noted in the Book Promotion Eligibility Requirements and Legal type stuff, the winners have 8 days to submit their information. Within 3 days of receipt of your email, we will reply to let you know we got it. If you don't hear back, the goat might have eaten your email. Please let us know by posting in the Ranch Office so we can check on it. Once you have received your copy please let us know by editing the Book Promotions Winners Page and updating the 'Status' column to say you have it.

Thanks and congrats to all the winners.

1 month ago
This week, we're delighted to have Bryson Payne helping to answer questions about the new book Learn Java the Easy Way: A Hands-On Introduction to Programming

The promotion starts Tuesday, December 5th, 2017 and will end on Friday, December 8th, 2017.

We'll be selecting four random posters in this forum to win a free copy of the book provided by the publisher, No Starch Press.

Image from unknown

Please see the Book Promotion page to ensure your best chances at winning!

Posts in this welcome thread are not eligible for the drawing, and should be reserved for welcoming the author. Questions posted in this topic are subject to removal.
1 month ago

David Simkulette wrote:
Here is an implementation of the hierarchy you described just as you described it. It does not compile because the invocation to removeItems () is ambiguous, as reported by the compiler. This is also what is expected.

Jessy issue isn't a compiler error. It is calling a method which is not what was expected. To understand the issue, we need the OP to give us an actual example that demonstrates it.  At this point, we are only guessing on what the OP's confusion is.

1 month ago

Conversions for assignments are defined by section 5.2 of the Java Language Specification ... https://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.2

Conversions for Method calls (passed values) are defined by section 5.3 of the JLS ... https://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.3

Noticed that there is a part regarding "compile time constants" in section 5.2, but this part does not exist in section 5.3?

Anyway, it does make sense right? If you are the compiler, and you are generating code for the method, how the heck are you going to detect that it is a compile time constant? The calling code may be in a completely different class, may be in many classes, and may even be in classes that haven't been written yet.

1 month ago