public class W4P7{
    public static void main(String []args){

        int [] myArray = {11, 29, 21, 23, 33, 32};

    }//end of main
        /****************start of method****************/
        public static void method(int [] x)
            int swap;
                for(int i=0; i<x.length;i++){
                    for(int j=0; j<x.length-1;j++){
                    if(x[j] > x[j+1]){
                        swap = x[j];
                    }//end of if
                }//end of for
            }//end of for

        /****************end of method****************/
}//end of class

It just prints out a blank screen

4 Years
Discussion Span
Last Post by stultuske

To display things on a screen you need to ask for it explicitly, for example using some of the many tools available in Swing or using System.out which is a java.io.PrintStream. If you only tell Java to do a thing, it will only do it and report nothing back to you.

If you just want to quickly see the content of myArray, you can write it to the standard output stream like this:


Usually the standard output stream will be visible to you.


also: a small note here...

It just prints out a blank screen

this is not a question, it is a statement. and everyone that went through your code could only say: "so it does".

if you want us to be able to help, be a bit more specific. do you want the array to be printed after it's sorted? do you want the two values being swapped each time being printed? ...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.