Home > Java > javaTutorial > Share an example of a classic Java programming question

Share an example of a classic Java programming question

零下一度
Release: 2017-06-25 10:55:27
Original
1488 people have browsed it

There are n integers, so that the previous numbers are moved backward by m positions, and the last m numbers become the first m numbers.

public class Example36 {
public static void main(String[] args) {
int[] m = { 18, 12, 23, 34, 95, 76, 57, 28, 9 };
moveElement(m, 5);
}

public static void moveElement(int[] m, int n) {
System.out.print("Before shifting The array is: ");
for (int r : m) {
System.out.print(r + " ");
}

if (n <= m. length) {
int[] b = new int[m.length];
for (int i = 0; i < m.length - n; i++) {
b[i + n] = m[i];
          }
                 int j = 0; m[i];
j++;
R: B) {
System.out.print (R + "");
}
} Else {## System.out.print ("\ n Move errors!") # }
}
}

The above is the detailed content of Share an example of a classic Java programming question. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template