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 8980399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:04:43+00:00 2026-06-15T20:04:43+00:00

Suppose I have 10 lines of code. Any line maybe throw a NullPointerException. I

  • 0

Suppose I have 10 lines of code. Any line maybe throw a NullPointerException. I don’t want to care about these exceptions. If a line throws the exceptions, I want the executor jump to next line and go forward. Could I do this on Java? if yes, please give me some sample code.

UPDATE: (add sample source for more clear question)

first.setText(prize.first);
second.setText(prize.second);
third.setText(prize.third);
fourth.setText(prize.fourth);
fifth.setText(prize.fifth);
sixth.setText(prize.sixth);
seventh.setText(prize.seventh);
eighth.setText(prize.eighth);

Suppose I have 8 lines of code above. What I want is: if the line 4 (or 5, 6,…) throws an exception, all other lines of code works normally. Of course I can use try…catch to catch the exceptions line by line. But this way make my source very complex.

  • 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-15T20:04:44+00:00Added an answer on June 15, 2026 at 8:04 pm

    The fact that a variable is null is notable, and should not be ignored. Therefore, you’d want something like this:

    ...
    if(first != null && prize.first != null)
    {
        first.setText(prize.first);
    }
    ...
    

    If, for some reason, you absolutely need to throw NPEs, you would need to surround each line with its own try/catch; there’s no way to automatically catch exceptions and have it advance to the next line. It’s not, however, recommended to do this.

    ...
    try
    {
        first.setText(prize.first);
    }
    catch(NullPointerException e)
    {
    }
    try
    {
        second.setText(prize.second);
    }
    catch(NullPointerException e)
    {
    }
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have an XSD file having below lines of code; <xsd:simpleType name=test> <xsd:restriction
Suppose I have a line of code that starts like the following: Func1(Func2(Func3 Is
Suppose I have a file containing some lines: line 1 ... line 2 ...
Suppose I have a class representing order lines , eg public class Line {
Suppose I have an order which has order lines and we have a multi-user
Suppose I have two documents that are identical except the lines are shuffled. Is
/* Suppose I have a multi-line comment with hard line-breaks * that are roughly
Suppose I have the following senario: Trunk is my main development line where programmers
suppose i have the following code: >>> a = re.finditer((?P<char>\w),hello world) >>> for i
Suppose there is a function with 1000 code of line named LongFunction, and we

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.