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


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

            method(myArray);
    }//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];
                        x[j]=x[j+1];
                        x[j+1]=swap;
                    }//end of if
                }//end of for
            }//end of for




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

It just prints out a blank screen

Recommended Answers

All 2 Replies

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:

System.out.println(java.util.Arrays.toString(myArray));

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? ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.