Click here to Skip to main content
15,915,319 members
Home / Discussions / Java
   

Java

 
QuestionDelimiters Pin
Member 107286679-Aug-15 10:58
Member 107286679-Aug-15 10:58 
AnswerRe: Delimiters Pin
Richard MacCutchan10-Aug-15 0:56
mveRichard MacCutchan10-Aug-15 0:56 
QuestionJava Bubble Sort Pin
Frankie12457-Aug-15 5:00
Frankie12457-Aug-15 5:00 
I recently did a project that asked the user to input a certain number of elements and then sort those in descending order.

I want to change it where there is no user input if the knowledge of the array is already been established for 10 integers in random order. Then sort them in descending order. 9876...etc

C#
import java.util.Scanner;

class BubbbleHW {
  public static void main(String []args) {
    int num,
    int i,
    int j,
    int temp;
/*This will no longer be needed    
Scanner input = new Scanner(System.in);


  System.out.println("Enter the number of elements to sort:");
    num = input.nextInt();
This will no longer be needed*/

    int array[] = new int[num];
//Do I change  int array[] = new int [9]

//    System.out.println("Enter " + //num + " elem,ents: ");

    for (i = 0; i < num; i++)
      array[i] = input.nextInt();

    for (i = 0; i < ( num - 1 ); i++) {
      for (j = 0; j < num - i - 1; j++) {
        if (array[j] < array[j+1])
        {
          temp = array[j];
          array[j] = array[j+1];
          array[j+1] = temp;
        }
      }
    }

    System.out.println("Decended order of elemtns");

    for (i = 0; i < num; i++)
      System.out.println(array[i]);
  }
}&lt;/pre&gt;</pre>

QuestionRe: Java Bubble Sort Pin
Richard MacCutchan7-Aug-15 6:21
mveRichard MacCutchan7-Aug-15 6:21 
AnswerRe: Java Bubble Sort Pin
Frankie12457-Aug-15 6:37
Frankie12457-Aug-15 6:37 
GeneralRe: Java Bubble Sort Pin
Richard MacCutchan7-Aug-15 21:09
mveRichard MacCutchan7-Aug-15 21:09 
GeneralRe: Java Bubble Sort Pin
Frankie12459-Aug-15 9:33
Frankie12459-Aug-15 9:33 
GeneralRe: Java Bubble Sort Pin
Richard MacCutchan10-Aug-15 0:54
mveRichard MacCutchan10-Aug-15 0:54 
GeneralRe: Java Bubble Sort Pin
Frankie124510-Aug-15 3:22
Frankie124510-Aug-15 3:22 
GeneralRe: Java Bubble Sort Pin
Richard MacCutchan10-Aug-15 3:34
mveRichard MacCutchan10-Aug-15 3:34 
Questioncennect unicenta with a phone problem Pin
Member 116403425-Aug-15 4:56
Member 116403425-Aug-15 4:56 
AnswerRe: cennect unicenta with a phone Pin
Richard MacCutchan5-Aug-15 5:23
mveRichard MacCutchan5-Aug-15 5:23 
QuestionJava Application Help - Inner Class? Pin
Member 1072866731-Jul-15 21:43
Member 1072866731-Jul-15 21:43 
AnswerRe: Java Application Help - Inner Class? Pin
Afzaal Ahmad Zeeshan2-Aug-15 1:55
professionalAfzaal Ahmad Zeeshan2-Aug-15 1:55 
QuestionJAVA SERVLETS and PHP Pin
anaQata31-Jul-15 5:10
professionalanaQata31-Jul-15 5:10 
AnswerRe: JAVA SERVLETS and PHP Pin
Richard MacCutchan1-Aug-15 22:10
mveRichard MacCutchan1-Aug-15 22:10 
GeneralRe: JAVA SERVLETS and PHP Pin
anaQata1-Aug-15 23:21
professionalanaQata1-Aug-15 23:21 
GeneralRe: JAVA SERVLETS and PHP Pin
Richard MacCutchan2-Aug-15 1:12
mveRichard MacCutchan2-Aug-15 1:12 
AnswerRe: JAVA SERVLETS and PHP Pin
Member 119648056-Sep-15 22:58
Member 119648056-Sep-15 22:58 
QuestionJava Pin
jubayer30-Jul-15 0:29
jubayer30-Jul-15 0:29 
AnswerRe: Java Pin
Pete O'Hanlon30-Jul-15 0:45
mvePete O'Hanlon30-Jul-15 0:45 
QuestionJava Set Game Pin
Member 1186286325-Jul-15 6:58
Member 1186286325-Jul-15 6:58 
AnswerRe: Java Set Game Pin
Richard MacCutchan25-Jul-15 8:17
mveRichard MacCutchan25-Jul-15 8:17 
QuestionJava Applet Help Pin
Member 1072866723-Jul-15 0:38
Member 1072866723-Jul-15 0:38 
AnswerRe: Java Applet Help Pin
Richard MacCutchan23-Jul-15 21:12
mveRichard MacCutchan23-Jul-15 21:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.