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

  • Home
  • SEARCH
  • 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 8346369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:59:31+00:00 2026-06-09T06:59:31+00:00

How can I store an integer in two digit format in Java? Like can

  • 0

How can I store an integer in two digit format in Java? Like can I set

int a=01;

and print it as 01? Also, not only printing, if I say int b=a;, b should also print its value as 01.

  • 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-09T06:59:32+00:00Added an answer on June 9, 2026 at 6:59 am

    I think this is what you’re looking for:

    int a = 1;
    DecimalFormat formatter = new DecimalFormat("00");
    String aFormatted = formatter.format(a);
    
    System.out.println(aFormatted);
    

    Or, more briefly:

    int a = 1;
    System.out.println(new DecimalFormat("00").format(a));
    

    An int just stores a quantity, and 01 and 1 represent the same quantity so they’re stored the same way.

    DecimalFormat builds a String that represents the quantity in a particular format.

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

Sidebar

Related Questions

i got a question about unsigned char array. How can i store an integer
I am trying to store two integer value into an char array in C++.
i was reading about how you can only pass by value in java and
This is a follow up question . So, Java store's integers in two's-complements and
I like how Java has a Map where you can define the types of
How can I convert two unsigned integers that represent the digit and decimal part
i am looking for a data structure to store two dimensional integer arrays. Is
I have two questions. How can I get the SQLite Db to store data?
I can store Session State in InProc or State Server or Sql Server. If
how we can store the e mail id into a database? i mean which

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.