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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:52:43+00:00 2026-06-15T17:52:43+00:00

I’m not really sure how to word this, but basically I want to read

  • 0

I’m not really sure how to word this, but basically I want to read in an rgb color in xxx, xxx, xxx format and store each xxx in an array. I am making a program to convert rgb into hexadecimal. Until I get my gui created (which may take me some time) I am executing and inputting in the terminal.

Currently this is what I am doing:

System.out.println("Enter the first set:");
rgb[0] = new Scanner(System.in).nextInt();`
System.out.println("Enter the second set:");
rgb[1] = new Scanner(System.in).nextInt();
System.out.println("Enter the third set:");
rgb[2] = new Scanner(System.in).nextInt(); 
  • I have seen people use .split(","), is this the best way to do what I want?
  • Would a regular expression work better?
  • Anyone know any tutorials that I could use? Most of the ones I have found have just left me more confused than I already was.

Just so you know I am not doing this for a project (before anyone accuses me). I already have the algorithm and everything else works except for this.

  • 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-15T17:52:45+00:00Added an answer on June 15, 2026 at 5:52 pm

    Here are my suggestions:

    • Don’t create a new Scanner instance each time you want to read input. Just create one at the beginning of the program and reuse it throughout.

    • The split method takes a regular expression as its argument, and returns a String[] (splitting the string on each match of its argument). So if you’re planning on parsing a string of the form "xxx, xxx, xxx" then .split(",\\s*") is probably your best bet. \s matches any whitespace character and \s* matches \s zero or more times.

    • I’m assuming rgb is an int[], so you could loop through your String[] that was obtained from split (as described above), call Integer.parseInt on each element, and add the parsed int to rgb.


    Relevant documentation

    • String#split
    • Integer#parseInt
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I need to clean up various Word 'smart' characters in user input, including but
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.