Created
July 28, 2018 07:57
-
-
Save mevlanaayas/94e26b030f86eba4e6aac6781ff1bfb1 to your computer and use it in GitHub Desktop.
Implementig integer add operation with ArrayList without any usages of arithmetic operations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Scanner; | |
public class AddWithoutArithmeticOperator { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
int numberOne = scanner.nextInt(); | |
int numberTwo = scanner.nextInt(); | |
int[] firstIntArray = new int[numberOne]; | |
int[] secondIntArray = new int[numberTwo]; | |
System.out.println(merge(firstIntArray, secondIntArray)); | |
} | |
private static int merge(int[] one, int[] two) { | |
ArrayList<Integer> combinedArray = new ArrayList<Integer>(); | |
for ( int n : one) combinedArray.add(n); | |
for ( int n : two) combinedArray.add(n); | |
return combinedArray.size(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment