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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:02:42+00:00 2026-06-03T01:02:42+00:00

String s = 000000001; String e = 009999999; Convert String 000000001 to Integer 000000001

  • 0
String s = 000000001;
String e = 009999999;

Convert String 000000001 to Integer 000000001.

I tried doing this with Integer.parseInt

int n = Integer.parseInt(s);

I am getting n = 1, but I want n should have 000000001

for (int ind = Integer.valueOf(s); ind < Integer.valueOf(e); ind++)  {

  String pp = "ggg" + ind; // I want pp should be like this- ggg000000001 and it keep on increasing like   ggg000000002, then ggg000000003 and etc etc.   
}
  • 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-03T01:02:43+00:00Added an answer on June 3, 2026 at 1:02 am

    The integer 000000001 is 1. I can only assume you want to display 1 as 000000001. This is how you do it:

    System.out.format("%09d", n);
    

    Here’s a little test:

    public static void main(String[] args) throws Exception {
        String s = "000000001";
        int n = Integer.parseInt(s);
        System.out.format("%09d", n);
    }
    

    Output:

    000000001
    

    FYI System.out.format() is a convenience facade for System.out.println(String.format()), so if you need the String in your code (and don’t want to output it) use:

    String s = String.format("%09d", n);
    

    Updated due to question update:

    String pp = String.format("ggg%09d", ind);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a assignment about this. For Eaxmple: I have a message (String),
String's in C# are immutable and threadsafe. But what when you have a public
I have a string with 14 characters . This is a hex represantation of
Hello I'm trying to save string into SQLite database, but nothing happens. I have
I have a very small number and I want to convert it to a
I'm trying to convert a float to a string without getting scientific (1.13E-8) style
string binary = Convert.ToString(15, 2); Console.WriteLine({0}, binary); Prints: 1111 I want it to print
Possible Duplicate: Convert a long hex string in to int array with sscanf I
How to convert x = 0x000000001 # hex number string to y = 1
Spring: In my context.xml, I have: <util:set id=someIDs set-class=java.util.HashSet value-type=java.lang.String> <value>W000000001</value> <value>W000000003</value> <value>W000000009</value> </util:set>

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.