fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13. String[] A = {"europe", "france", "germany", "america"};
  14.  
  15. String[] new_Array;
  16. // your code goes here
  17. int x=2,y=3;
  18. int start_concat = x-1 ; // to account for array index
  19.  
  20. int stop_concat = start_concat+y;
  21.  
  22. new_Array = new String[A.length-y + 1];
  23.  
  24. for(int i=0; i<=start_concat; i++){
  25. new_Array[i] = A[i];
  26. }
  27.  
  28. for(int i = start_concat+1 ; i<stop_concat; i++){
  29. new_Array[start_concat] = new_Array[start_concat] + A[i];
  30. }
  31.  
  32. for(int i =start_concat+1, j=stop_concat ; i< new_Array.length;i++,j++){
  33. new_Array[i] = A[j];
  34. }
  35.  
  36. for(int i=0; i<new_Array.length; i++){
  37. System.out.println(new_Array[i]);
  38. }
  39. }
  40. }
Success #stdin #stdout 0.06s 27840KB
stdin
Standard input is empty
stdout
europe
francegermanyamerica