Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all
I am using "Jcreator v3" and "Eclips" to run my code but the last application didn't see my code , after run my code I see just the black form,please tell me why this code didn't work ?
This code to sort an array .
This is my code :
Java
import javax.swing.JOptionPane;

public class anything {


	public static void main(String[] args) 
	
	{
	// inserting array
		int [] RandomArray = {1,2,5,3,4,6,7,8};
	
		
	//sorting array "Here the program didn't read"
		int [] Sortedarray = new int  [8];
		for (int i = 0; i < RandomArray.length; i++) 
		{
			int count = 0 ;
				int x=0;
			for (int j = 0; j < RandomArray.length; j++) 
			
			
			{
				if (RandomArray[i]!=0)
					
			
					{
					
			
					if (RandomArray[i]<RandomArray[j])
				
					{
					
						
						Sortedarray[count] = RandomArray[i];
					x=i;
				
					}else
				
					{
						Sortedarray[count] = 	RandomArray[j];
						i=j;
						x=j;					
					}
				
			
					
					
					}
					
				
				
			}
					RandomArray[x]=0;
					count=count+1;	
					i=0;
		}
		
		
		
		//write sorted array
		Sortedarray[0]=1;
		for (int z = 0; z < Sortedarray.length; z++) 
		{
			System.out.println("This is sorted array:"+Sortedarray[z]);
		}

		
		
		

	}

}
Posted

1 solution

Check the comment below

C#
import javax.swing.JOptionPane;

public class anything {


    public static void main(String[] args)

    {
    // inserting array
        int [] RandomArray = {1,2,5,3,4,6,7,8};


    //sorting array "Here the program didn't read"
        int [] Sortedarray = new int  [8];
        for (int i = 0; i < RandomArray.length; i++)
        {
            int count = 0 ;
                int x=0;
            for (int j = 0; j < RandomArray.length; j++)


            {
                if (RandomArray[i]!=0)


                    {


                    if (RandomArray[i]<RandomArray[j])

                    {


                        Sortedarray[count] = RandomArray[i];
                    x=i;

                    }else

                    {
                        Sortedarray[count] =    RandomArray[j];
                        i=j;
                        x=j;
                    }




                    }



            }
                    RandomArray[x]=0;
                    count=count+1;
                    i=0; //********Problem is here i is being reinitialized to 0 so the loop never ends
        }



        //write sorted array
        Sortedarray[0]=1;
        for (int z = 0; z < Sortedarray.length; z++)
        {
            System.out.println("This is sorted array:"+Sortedarray[z]);
        }





    }

}
 
Share this answer
 
Comments
[no name] 1-Jul-14 8:15am    
You had to repost the entire code base just for that?!?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900