write a Java method to delete the last occurrence of the integer that was chosen by the user from the array and then prints the updated contents of the array.
1
Expert's answer
2012-12-05T09:38:11-0500
public static void main(String[] args) { int[]a=new int[5]; gen(a);
for(int i = 0; i < a.length; i++) { System.out.print(a[i]+""); }
Scanners=new Scanner(System.in);
System.out.println(" enterindex of element to delete");
/** * fill array with random values * @param a */ publicstatic void gen(int[] a) { for(inti=0;i<a.length;i++) { a[i]=(newRandom()).nextInt(100); } } /** * delete element from array with index i * @param i * @return */ publicstatic int[] delete(int i, int a[]) { int[]arr=new int[a.length-1]; intcnt=0;
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment