Question: **please don't use handwriting Please complete the method delete, run the program and send me in image of the run output. public class Rev{ public
**please don't use handwriting
Please complete the method delete, run the program and send me in image of the run output.
public class Rev{ public static void main(String[] args){ int[] a = {10, 3, 21, 27, 1};
System.out.println(java.util.Arrays.toString(a)); System.out.println(java.util.Arrays.toString(insert(a, 2, 4))); } private static int[] delete(int[] a, int pos){ int[] temp = new int[a.length - 1]; // YOUR CODE GOES HERE return temp; }
private static int[] insert(int[] a, int pos, int value){ int[] temp = new int[a.length + 1]; int i = 0; for(; i < pos; i++) temp[i] = a[i]; temp[pos] = value; for(; i < a.length; i++) temp[i + 1] = a[i]; return temp;
} private static int compare(String s1, String s2){ int limit = (s1.length() < s2.length()) ? s1.length() : s2.length();
for(int i = 0; i < limit; i++) if(s1.charAt(i) < s2.charAt(i)) return -1; else if(s1.charAt(i) > s2.charAt(i)) return 1; return s1.length() - s2.length(); } private static String substring(String s, int from, int to){ String r = ""; for(int i = from; i < to; i++) r += ""+s.charAt(i); return r; }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
