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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:28:06+00:00 2026-06-07T10:28:06+00:00

In my coding various places i need to change integer values to string values.

  • 0

In my coding various places i need to change integer values to string values. To convert the cast integer to string i use concatenation with “” to integer.

i found an another way that is using String.parseInt(..); method.

my question is i do not know which is optimized method to do casting in java and how it is optimized?. is there any other way to cast except my code?

my sample code:

int total = mark1 + mark2;
String str_total = ""+total;  // currently doing.

…….

String str_total = String.parseInt(total);  // i am planning to do.
  • 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-07T10:28:08+00:00Added an answer on June 7, 2026 at 10:28 am

    You can also use –

    String str_total = String.valueOf(total); 
    

    OR

    Use Integer rahter than int in your code and then use toString() on Integer like

    Integer total = mark1 + mark2;
    String str_total = total.toString();
    

    In your code –

    String str_total = “” + total;

    Actually you are creating 2 new string objects first for "" and second str_total

    but in my code only one new string object will be created.

    Implementation of valueOf in String class is as follows –

       public static String valueOf(int i) {
            return Integer.toString(i);
        }
    

    here toString will create a new String object

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

Sidebar

Related Questions

I am coding for various programming olympiads and am trying to improve time efficiency.
I have just a question... I'm seeing this coding style in various php scripts
The coding like decimal prodprice = Convert.ToDecimal(NavigationContext.QueryString[Price]); then what should i put for Binary
In various places I've seen the claim that by designing a system up-front, you
I'm trying to do some IP agnostic coding and as suggested by various sources
I have 2 questions Q1: I have read about various coding indent styles like
I have been coding in python/django and c/c++ from last three years for various
We use the CellFormatting event to colour code cells in various grids all over
I'm coding a SQL query to look for events in a database. I use
I've found various proposed solutions to this problem on this internet, but none of

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.