Ketung Xiao

Greenhorn
+ Follow
since Jul 22, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ketung Xiao


Class ArrayList has add method with this signature:


In the following code:



the add method does not necessary return boolean,
can someone give an example that explain the the purpose of boolean instead of void
in ?

Thanks.
6 years ago

In the Java doc API : ocs\api\java\time\LocalDate.html
LocalDate shows no constructor,
so does LOcalDate use super Object class constructor ? how does that work ?

Hope someone find my question interesting.
Thanks.
6 years ago

Please let me know answer to this question:

How do I reset the email notification request  back to 'YES' on this thread ?
Thanks,
6 years ago
How do I reset the email notification request  back to 'YES' on this thread ?
I inadvertently click on the email link to turn off email notification on this thread.


The following code will run:

6 years ago
So, you are say: IndexOutOfBoundsException which is subclass of java.lang.RuntimeException CANNOT be caught or thrown ?
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.IndexOutOfBoundsException
6 years ago

I meant to include your quote: I think it compiles because it is not forbidden to catch runtimeexceptions.

I Agree, and if the code catch runtimeexceptions or "uncheck" exception which include error exception, it will work just like "checked" exception.

By the way, is there a way to delete my own quote after I submit a post ?
6 years ago

Marius Zilenas wrote:I think it compiles because it is not forbidden to catch runtimeexceptions.

Agree, and if the code catch runtimeexceptions or "uncheck" exception which include error exception, it will work just like "checked" exception.

6 years ago

Definition of "checked" exception: subclass of Exception but not subclass of RuntimeException.

"checked" exception must be caught or thrown to be compiled; while "unchecked" exception has option to be caught or thrown for successful compilation.
"unchecked" has option to be caught or thrown just like "checked" exception and if caught or throw will work just like "checked" exception.

Thank you for your reply and if this is not right, please reply.




6 years ago
I'm more confused than was before.  
The following code will compile. But it calls  Boolean kh = Array.getBoolean(value, 5) which has this method signature:


[/color]
which make me think, caller must catch or throw !!! otherwise it should not compile


6 years ago

The called Java method can throws any type of exception, and the calling method must catch it or throw it.
I read somewhere that Java has 2 types of exception: "checked" and "unchecked" and that "checked" must be subclass of Exception but not subclass of "RuntimeException".
This was the reason for my original post.

Now, I think the the "checked" exception is referring to the JDK methods that has "throws" clause.






6 years ago