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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:26:56+00:00 2026-06-11T06:26:56+00:00

it has been 8 years since I last programmed, and then it was just

  • 0

it has been 8 years since I last programmed, and then it was just basics for a networking degree. I am writing a basic program to start my way back into java programming. the program is dealing with binary numbers stored as strings.

e.g. 01101110010

I have got everything else working, but now I want to swap all “1” for “0” and all “0” for “1”

to get 10010001101

The problem is the only way I know to swap chars is to create a new string with the chars replaced but I can only do one char at a time and then I just end up with a string of all 1s or 0s

so I thought about using a char array and trying to swap each char in the array but I have no idea how to go about 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-11T06:26:58+00:00Added an answer on June 11, 2026 at 6:26 am
    String str = "0101010101110";
    char[] cs = str.toCharArray();
    for (int i = 0; i < cs.length; i++)
    {
        if (cs[i] == '1')
            cs[i] = '0';
        else if (cs[i] == '0')
            cs[i] = '1';
    }
    str = new String(cs);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It has been many years since I last typed <frameset> into my editor, but
It's been a few years since I have last developed android apps. Since then,
I have a travel related website that has been online for several years (since
This has been working for years then about 6 weeks ago or so the
My web app has been chugging along just great in Production for years with
It has been many years since i played around with AS2 and can't seem
First, I'll admit this is homework but it has been around six years since
It's been at least 5 years since I worked with Java, and back then,
It seems like v2 of Log4j has been in development for literally years. The
So, it's been about 3 years since I wrote and went live with my

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.