public static void main(String args[]){
int num[] = {1,2,3,5,6,7};
int newNum = 4;
for(int index = 0 ; index < num.length ; index++){
if(newNum < num[index]){
newNum = newNum + num[index];
num[index] = newNum - num[index];
newNum = newNum - num[index];
}
}
for(int index = 0 ; index < num.length ; index++){
System.out.println(num[index]);
}
}
}
Try this source code
Hi.
Suppose i had this code below:
------------------------------------------------------------------
package sorting;
public class sorting {
public static void main(String[] args) {
int [] n = {1,2,3,5,6,7};
/* here i want to add number 4 and perform sorting and shifting on the array so that it contains those elements:
n = {1,2,3,4,5,6}; */
}}
plz make it simple solution because im still a starter;
i know the basics like :
the loops;
classes;
file io not that much;
and actually those numbers im going to read them from a file but i think i can mange that;
THanx.