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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:37:26+00:00 2026-05-25T12:37:26+00:00

Hi i got the following code which i use to get some integers from

  • 0

Hi i got the following code which i use to get some integers from a string. I am separating successfully the negative and positive integers by combining the string with the next number if the char at the index is “-” and i can put the numbers in an integer array…

   //degree is the String i parse

   String together="";
      int[] info=new int[degree.length()];
      int counter=0;

       for (int i1 = 0; i1 < degree.length(); i1++) {

         if (Character.isSpace(degree.charAt(i1))==false){ 
            if (Character.toString(degree.charAt(i1)).equalsIgnoreCase("-")){
                together="-";
                             i1++;

            }
             together = together + Character.toString(degree.charAt(i1));

            info[counter]=Integer.parseInt(together);
         }
         else if (Character.isSpace(degree.charAt(i1))==true){
             together ="";
            counter++;
         }

But i go this strange problem….the string looks exactly like “4 -4 90 70 40 20 0 -12” and the code parses and puts the integers into the array only to the “0” number i mean i get all the number negatives and positives into my array except the last “-12” number… any ideas?

  • 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-05-25T12:37:26+00:00Added an answer on May 25, 2026 at 12:37 pm

    I think there’s a much simpler solution to your problem:

    // First split the input String into an array,
    // each element containing a String to be parse as an int
    String[] intsToParse = degree.split(" ");
    
    int[] info = new int[intsToParse.length];
    
    // Now just parse each part in turn
    for (int i = 0; i < info.length; i++)
    {
        info[i] = Integer.parseInt(intsToParse[i]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my app I've got certain buttons which use the following code: SystemSoundID beep;
Ive got the following code which I hacked together from website examples. It works
Hi all i've got the following code which will go off and get all
i've got the following code which runs a bat file. the bat file then
I've got the following code in my Services project, which is trying to grab
I have got the following code from here to read an Excel file using
I've got the following code that I am trying to use to access a
I would like to get some information from a website. I have already got
I have a project in c# which uses bindings to use some c++ code.
I took some code from my C# Windows form app which uses the Application

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.