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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:26:49+00:00 2026-06-07T13:26:49+00:00

[Solved] I’ve searched many forums as well as Stack Overflow’s questions for converting an

  • 0

[Solved]

I’ve searched many forums as well as Stack Overflow’s questions for converting an ever changing random number to a string but I couldn’t find a solution to my specific problem.

How do I go about converting customerID to a string?

    public class UniqueCustomerNumber {

    private int customerID;

    public void setCustNum(int cNumber) {
        Random x = new Random();
        cNumber = x.nextInt(800000001) + 100000000;
        customerID = cNumber;
    }

    public int getCustNum() {
        return customerID;
    }
}
  • 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-07T13:26:51+00:00Added an answer on June 7, 2026 at 1:26 pm

    Use Integer.toString(int i) It’s a static method in Integer class that takes one int as an agument and returns its textual representation as String.

    public class UniqueCustomerNumber {
    
        private String customerID;
    
        public void setCustNum() {
            Random x = new Random();
            this.customerID = Integer.toString(x.nextInt(800000001) + 100000000);
        }
    
        public String getCustNum() {
            return this.customerID;
        }
    }
    

    Code:

    public class UniqueCustomerNumberTest {

    public static void main(String[] args) {
        UniqueCustomerNumber uin = new UniqueCustomerNumber();
        uin.setCustNum();
        System.out.println("Unique Customer Number = " + uin.getCustNum());
    }
    

    Output:

    Unique Customer Number = 748816502
    

    A side note: Using this method may not be in compliance with your class name, UniqueCustomerNumber. I know that the probability is really small, but it could theoretically happen that 2 customers have the same IDs if you generate them this way. A much simpler approach is to start assigning cutomers their IDs starting from some number, 1, for example.

    On each assignment, you’d increase your counter by 1. The downside is that you’d need to keep that counter saved somewhere (DB, txt file, w/e).

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

Sidebar

Related Questions

SOLVED! My Activity Stack looks like this, excuse the rough diagram! A-->B-->C '-->D If
SOLVED http://jsfiddle.net/ArtofLife/u9d9d/ I have multiple TEXTAREA and BUTTON out side.. For inserting string in
solved I changed the bfs::directory_iterator Queue to a std::string queue, and surprisingly solved the
Solved! After following Matti's suggestions, I removed the custom functions and all is well.
Solved I actually found out what is going on here. Turns out it was
solved: IstBestellwert = grouped.Sum(o => (double)o.SollMenge * (double)o.Preis) works My SQL Statment SELECT ABId,
SOLVED in the last answer im getting following error, dunno where and why? cause
@Solved The two subquestions I have created have been solved (yay for splitting this
SOLVED. Code has been edited to reflect solution. Given the following GridView : <asp:GridView
SOLVED: This is what was wrong: current.addFolder(folder); (in the final else clause of the

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.