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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:21:43+00:00 2026-06-17T15:21:43+00:00

Below is the code snippet , where I am confused .The return type of

  • 0

Below is the code snippet , where I am confused .The return type of method is int , so the method can not return null.But , when I uncomment 1st return statement and comment 2nd return statement, method’s doesn’t show any error not even warning.
I am confused what is the reason behind that.I am using java version 7.

 protected int calculateLogicalPageRangeForTitles(String logicalpage) throws Exception {
     //return StringUtils.isNumeric(logicalpage) ? Integer.parseInt(logicalpage) : null;
     return null;
 }
  • 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-17T15:21:44+00:00Added an answer on June 17, 2026 at 3:21 pm

    The code is legal and compiles.

    See Java Spec:
    http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.25

    If one of the second and third operands is of the null type and the
    type of the other is a reference type, then the type of the
    conditional expression is that reference type.

    This means, the result of the ?: will be an Integer, which will be unboxed to int. This unboxing will throw a NullPointerException.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am not understanding how below code snippet can be made thread safe. class
Below is a code snippet from a book. Why can serialNumber still be set
Can we use namespaces like in below snippet? The code compiles in both gcc
I have stumbled upon the following problem. The below code snippet does not link
i have below code snippet. It throws the exception at line 3 but query
i have below code snippet. I am not getting how to change the color
The below code snippet is used to convert a string to lower case. int
Consider the below code snippet: #include <stdio.h> int main() { int p = malloc(
Below is code snippet in instance method String x = new StringBuffer().append(a).append(b).append(c).toString() i am
In below code snippet, although pointer is not initialized the call is still made

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.