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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:11:30+00:00 2026-05-26T02:11:30+00:00

its been awhile since i used java the last time and am trying to

  • 0

its been awhile since i used java the last time and am trying to brush up on couple of things.

import java.util.*;

public class bitStrings {
    public static void main(String [] args){

        Scanner inputBitString = new Scanner(System.in);        

        //input.
        String binArray;

        ArrayList<String> myArr = new ArrayList<String>();

        while(inputBitString.hasNext()){

            binArray=inputBitString.next();         
            myArr.add(binArray);
            System.out.println(myArr);      

            for(int i=0;i<myArr.size();i++){
                if(myArr(i)=="1") myArr(i)=="10";
                else myArr(i)=="01"
            }
        }

    }

}

So I want to store the input in an array from the user’s keyboard input. so if the user types “1010”, the for loop will go through the array and replaces the “1” with “10” and “0” with “01”.
so the resulting output will be “10011001”

Thanks

  • 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-26T02:11:31+00:00Added an answer on May 26, 2026 at 2:11 am

    You can use this:

    ArrayList<String> myArr = new ArrayList<String>();
    ArrayList<String> myArrDub = new ArrayList<String>();
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String str = bf.readLine();
    
    for (int i=0; i<str.length(); i++) {
        String tempStr = new String();
        tempStr += str.charAt(i);
        myArr.add(tempStr);
    }
    
    System.out.println(myArr);
    
    for(int i=0;i<myArr.size();i++){
        if(myArr.get(i).equals("1"))
        myArrDub.add("10");
    else
        myArrDub.add("01");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's been a while since I used GTK+, and the last time I did
It's been quite a while since I last used D Programming Language , and
It's been awhile since my algorithms class in school, so forgive me if my
It's been a while since I last coded arm assembler and I'm a little
I have been developing in asp.net since its existence (also classic asp before that)
Disclaimer: It's been a while since I last wrote any code. The quality of
It's been a while since I've had to do any HTML-like code in Vim
It's been a while since I've programmed a GUI program, so this may end
It's been a while since I was in college and knew how to calculate
It's been a while since I programmed in C++, and after coming from python,

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.