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
You can use this: