Row wise sorting in double dimensional using selection sort

Enter elements of matrix:
9
1
5
3
7
4
8
6
2
Original Matrix:
9 1 5
3 7 4
8 6 2
Matrix after sorting rows:
1 5 9
3 4 7
2 6 8

import java.io.*;
class MatrixSort{
    public static void main(String args[])
    throws IOException{
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(in);
        int a[][];
        int i = 0;
        int j = 0;
        int temp[];
        int k = 0;
        a = new int[3][3];
        temp = new int[3 * 3];
        System.out.println("Enter elements of matrix:");
        for(i = 0; i < 3; i++){
            for(j = 0; j < 3; j++){
                a[i][j] = Integer.parseInt(br.readLine());
                temp[k++] = a[i][j];
            }
        }
        System.out.println("Original Matrix:");
        for(i = 0; i < 3; i++){
            for(j = 0; j < 3; j++)
                System.out.print(a[i][j] + "\t");
            System.out.println();
        }
int z=0;
int min=0;
while(z<3*3)
{
for(int o=0;o<3*3;o=o+3)
{

        for(i = 0; i < 2; i++){
min=i+o;
            for(j = i+1; j < 3; j++)
{
                if(temp[j+o] < temp[min])
min=j+o;
}
int t = temp[i+o];
                    temp[i+o] = temp[min];
                    temp[min] = t;
                }
        k = 0;
        for(i = 0; i < 3; i++)
            for(j = 0; j < 3; j++)

                a[i][j] = temp[k++];}
z++;}
        System.out.println("Matrix after sorting rows:");
        for(i = 0; i < 3; i++){
            for(j = 0; j < 3; j++)
                System.out.print(a[i][j] + "\t");
            System.out.println();
        }
    }
}

Boxing & Unboxing in Java

What is boxing and unboxing?
Wrapper classes are those whose objects wraps a primitive data type within them. In the java.lang package java provides a separate class for each of the primitive data type namely Byte, Character, Double, Integer, Float, Long, Short.
Converting primitive datatype to object is called boxing.

Example

Integer obj = new Integer ("9339");
Whereas, converting an object into corresponding primitive datatype is known as unboxing.

Example

public class Sample {
   public static void main (String args[]){
      Integer obj = new Integer("9339");
      int i = obj.intValue();
      System.out.println(i);
   }
}

Output

9339

Second largest number in java using ternary operator

 //Largest second number using ternary operator public class Main { public static void main(String[] args) { int a=5,b=6,c=7; int ...