• Post Reply Bookmark Topic Watch Topic
  • New Topic

About NumberFormatException  RSS feed

 
João Victor Gomes
Ranch Hand
Posts: 113
11
Eclipse IDE Java Netbeans IDE Postgres Database Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I promise that I'm gonna sleep after this last question

Well, I thought I was doing good on Exceptions, but this is something that I don't understand.





The explanation says that NumberFormatException are always thrown programmatically, but if I run the following code, the JVM throws a NumberFormatException, since it is a RuntimeException:

I understand that it is often thrown by the programmer. But "always thrown programmatically" makes me remember of checked exceptions.
I believe I've read a topic about this discussion this week, but I couldn't find it right now.
Could you guys clarify this for me? Or post the link of the topic that I mentioned. I found it by accident, and now I can't find it again.
 
Roel De Nijs
Sheriff
Posts: 11338
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
João Victor Gomes wrote:Could you guys clarify this for me? Or post the link of the topic that I mentioned. I found it by accident, and now I can't find it again.

Let's see if I can start a clairvoyant carreer... Maybe you are referring to this topic?
 
João Victor Gomes
Ranch Hand
Posts: 113
11
Eclipse IDE Java Netbeans IDE Postgres Database Tomcat Server
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:
João Victor Gomes wrote:Could you guys clarify this for me? Or post the link of the topic that I mentioned. I found it by accident, and now I can't find it again.

Let's see if I can start a clairvoyant carreer... Maybe you are referring to this topic?


Haha, that's exactly the topic I was talking about. I knew you were there. I think you would be fine in your new carreer...
And I agree. Now I see the distinction between thrown by the JVM and thrown Programmatically. The parseInt (and other methods) throws the NumberFormatException, because someone wrote that it does. There is no such code to throw a NumberFormatException by accident.
Sometimes I forget about the fact that Java was created and is maintained by human beings hahaha
Now I don't miss it again. Programmatically thrown doesn't mean thrown by the programmer of the application.

Thanks.
 
Roel De Nijs
Sheriff
Posts: 11338
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
João Victor Gomes wrote:Haha, that's exactly the topic I was talking about. I knew you were there. I think you would be fine in your new carreer...

Glad to know I have a plan B if my Java developer carreer fails
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!