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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:57:34+00:00 2026-06-15T10:57:34+00:00

Looking at the answers to this question (link: How do I convert from int

  • 0

Looking at the answers to this question (link: How do I convert from int to Long in Java?), I used the following to compare long values (newUpdate, lastUpdate) with int value (Interval)

if ((newUpdate - lastUpdate) > Long.valueOf(interval))

I am not able to compile. What is the correct way to compare two different types?

More Info:

[INFO] Trace org.apache.maven.BuildFailureException: Compilation failure [145,51] operator > cannot be applied to long,java.lang.Long

Interval is of the type int.

  • 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-15T10:57:35+00:00Added an answer on June 15, 2026 at 10:57 am

    If interval is an int, then just …

        if ((newUpdate - lastUpdate) > interval) { ...
    

    There is NO good reason to explicitly convert interval to a long in this context. The conversion will be done for you anyway.

    The expression Long.valueOf(Interval) returns a java.lang.Long rather than a long. If you needed to explicitly turn interval into a long, then you should cast it:

        if ((newUpdate - lastUpdate) > ((long) interval)) {
    

    The only thing that puzzles me about your example is why you get a compilation error when comparing a long and a Long. The Long should be auto-unboxed and the long, long version of the > operator should be used: reference JLS – 15.20.1 which says that numeric relational operators perform unboxing if required. The only explanation can be that you are compiling with the source level at 1.4 or earlier.

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

Sidebar

Related Questions

I have been looking at the answer to this question: Pulling details from response
When I was looking at answers to this question , I found I didn't
All day I was looking an answer on this question: How to log in
While looking up the answer to this question: Why is an out parameter not
I've been looking for an existing answer to this question, but haven't found one.
I'm looking for an answer to a question similar to this one: protect users'
Thanks for looking, all helpful answers are voted up. This is my markup. I'm
I feel like this question has been asked before but the answers seem pretty
I'm looking for an information popup box like here on this site: Yahoo answers
I have been looking all over the Internet for an answer to this question

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.