Eswar
BAN USER
Don't take anything personally. If there is any argument on anything then try to explain the advantages/disadvantages by taking an example with everyone's approach. If both are suggesting the different approaches and the result is going to be the same without any performance impact then follow other's approach only, So that they will get the positive impression on you and it will be useful for the next time.
- Eswar October 12, 2013public class Subtract {
public static void main(String[] args) {
int[] A = {1,2,5,7,5};
int[] B = {3,4,8,9};
String result = String.valueOf(Integer.valueOf(getString(A)) - Integer.valueOf(getString(B)));
String[] resultStr = new String[result.length()];
System.out.println("Result: ");
System.out.print("{");
for(int loopCounter=0; loopCounter < result.length(); loopCounter++){
resultStr[loopCounter] = String.valueOf(result.charAt(loopCounter));
System.out.print(resultStr[loopCounter]);
if(loopCounter < (result.length()-1)){
System.out.print(", ");
}
}
System.out.print("}");
}
private static String getString(int[] array){
String str = "";
for(int loopCounter:array){
str = str + loopCounter;
}
return str;
}
}
- Eswar October 12, 2013