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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:06:03+00:00 2026-06-13T22:06:03+00:00

I am receiving a numeric value input parameter that is a String data type

  • 0

I am receiving a numeric value input parameter that is a String data type (something that I cannot change) and I need to check that this value received is of a certain number. I.e. Check if the value is 5.

Knowing that the received value of String data type, but at all times it will should contain only numbers. I would first convert the value into an integer data type, and then perform the equality test. I.e. Case B illustrated below.

Case A:

String expected = "3"; 

if(expected.equals(actual)) //...

Case B:

int expected = 3;

int actualInt = Integer.parseInt(actual);

if(expected == actualInt) //...

I would like to find out if there will be any cons in performing the equality test using Case B as I am more inclined to do it that way as a correct way out.

  • 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-13T22:06:04+00:00Added an answer on June 13, 2026 at 10:06 pm

    If you are only going to do equality check then I think case A is fine, since you are not doing any operations that will require you the number instead of a string.

    Only cons I could see with case B, is that you would have to parse the number out of the string for the equality check.

    But the advantage of case B is that if you needed to make sure that the string is actually an integer, in which case, you would have to go with case B.

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

Sidebar

Related Questions

Receiving this error: Error 4 'ZoneUpdates.Models.PgeDataContext.PgeDataContext(string, System.Data.Linq.Mapping.MappingSource)' must declare a body because it is
Why am I receiving this Rake error: $ rake --version /Volumes/Data/sampablokuper/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not
Receiving this error: a different object with the same identifier value was already associated
Im receiving error C2082: redefinition of formal parameter 'rval' in this code while trying
When receiving data through a socket using recv , I've noticed that, with: char
I keep receiving this error... [2012-06-14 11:54:50,072: ERROR/MainProcess] Hard time limit (300s) exceeded for
I am receiving this Uncaught TypeError on a new website I am creating, but
I am receiving a parse error which is this: Parse error: syntax error, unexpected
I am receiving shouldstartloadwithrequest event and I need to stop request for some conditions.
I'm receiving an xml response and I now want to parse this. Currently what

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.