Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:01:36+00:00 2026-06-12T04:01:36+00:00

I am trying to call a custom catch expression String value1 = side1_tb.getText(); String

  • 0

I am trying to call a custom catch expression

String value1 = side1_tb.getText();
String value2 = side2_tb.getText();
String value3 = side3_tb.getText();
try
{
    result_lbl.setText(
        actual_triangle.Triangle(
            Double.parseDouble(value1),
            Double.parseDouble(value2),
            Double.parseDouble(value3)));
}
catch (NumberFormatException exe)
{

}

So from the above code you can see that there are three textboxes values are being assigned to a string variables and then I implemented a try and catch method with ‘Numberformatexception’ but in the place of ‘Numberformatexception’ I want to implement a custom exception and this exception will be declared in another class lets call this class EXCEPTIONclass.java and in here I want to create an exception if String values are not being able to parse to double values, which I am trying to achieve in the above code.

Not really sure how to extend the exception class and then declare a new exception.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:01:37+00:00Added an answer on June 12, 2026 at 4:01 am

    You could do it as follows:

    public class MyCustomException extends Exception
    {
        // To keep compiler happy about Exception being serializable.
        // Note: This should carry meaningful value when these exceptions are going 
        // to be serialized
        public static final long serialVersionUID = 1L; 
    
        public MyCustomException(String message, Throwable t)
        {
            super(message, t);
        }
    
        // Other constructors of interest from the super classes.
    }
    

    In your catch block, you would wrap the NumberFormatException as follows:

    catch (NumberFormatException nfe)
    {
        throw new MyCustomException("<Your message>", nfe);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call a custom instance of a 403 HTTP error in Rails
I am trying to call OrderBy() using a custom IComparer on a SubSonic IQueryable
I'm trying to call from C# a function in a custom DLL written in
I'm trying to use jQuery to call some custom API via Ajax/$.getJSON . I'm
I'm trying to call a custom action within my Setup & Deployment project to
I am trying to call notifyDataSetChanged() on my custom adapter but it seems not
i'm trying to call notifyDataSetChanged for my custom ExpandableListView. what happens is for my
I'm trying to call a custom shell script through sh : /bin/sh -c 'myscript.sh`
I am trying to call my custom Htpp Handler and want to pass some
Im trying to call function on Custom Search Engine search button click. Code at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.