Programs of bubble sorting with buffered reader

Answers (1)
import java.io.*;

class sort

      String str;
      int size,sortArr[];
      
      publicvoid getdata()
      
             System.out.print("Enter how many data you want to enter : ");
             System.out.flush();
             try
                 BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
                 str=obj.readLine();
                 size=Integer.parseInt(str);
                 sortArr=newint[size];
                 for(int i=0;i<size;i++)
                   
                       System.out.print("Enter element at "+(i+1)+"th position  :  ");
                       System.out.flush();
                       str=obj.readLine();
                       sortArr[i]=Integer.parseInt(str);
                   
                
            catch(Exception e)  
      
                 
      publicvoid  BubSort()
      
            System.out.println("=====BUBBLE SORT=====
");
            getdata();
                for(int i=0;i<size;i++)
                    
                  for(int j=0;j<size-1;j++)
                      
                         if(sortArr[j] > sortArr[j+1])
                          
                               int temp=sortArr[j];
                               sortArr[j]=sortArr[j+1];
                               sortArr[j+1]=temp;
                          
                     
                  
            display();
            

    publicvoid display()
    
         System.out.println("
After Sorting");
         for(int i=0;i<size;i++)
              System.out.println(sortArr[i]);
    



class BubSort 

    publicstaticvoid main(String args[]) 
    
          sort ob1=new sort();
          ob1.BubSort();
    

Most Viewed Questions

Preparation Products

Knockout JEE Main April 2021 (One Month)

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 14000/- ₹ 4999/-
Buy Now
Knockout NEET Aug 2021 (One Month)

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 14000/- ₹ 4999/-
Buy Now
Knockout JEE Main May 2021

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 22999/- ₹ 9999/-
Buy Now
Knockout NEET Aug 2021

Personalized AI Tutor and Adaptive Time Table, Self Study Material, Weekend Live Classes, Mentorship from our Experts, Unlimited Mock Tests and Personalized Analysis Reports, 24x7 Doubt Chat Support,.

₹ 22999/- ₹ 9999/-
Buy Now
Test Series JEE Main May 2021

Unlimited Chapter Wise Tests, Unlimited Subject Wise Tests, Unlimited Full Mock Tests, Get Personalized Performance Analysis Report,.

₹ 6999/- ₹ 2999/-
Buy Now
Boost your Preparation for JEE Main with our Foundation Course
 
Exams
Articles
Questions