I found many solutions to solve this problem but i didn't get any of them. Can anyone please give me the simplest solution for the given problem.If possible please give answer in java language.
  Example-   
  Input : arr[] = {1, 2, 3}
  Possible Subset are:{}, {1}, {2}, {3}, {1, 2}, {1, 3}, 
                 {2, 3}, {1, 2, 3}
This program is not finding all the subsets
class Test
{
static int arr[] = new int[]{1, 2, 3, 4};
// Prints all subarrays in arr[0..n-1]
static void subArray( int n)
{
    // Pick starting point
    for (int i=0; i <n; i++)
    {
        // Pick ending point
        for (int j=i; j<n; j++)
        {
            // Print subarray between current starting
            // and ending points
            for (int k=i; k<=j; k++)
                System.out.print(arr[k]+"");
        }
    }
}
// Driver method to test the above function
public static void main(String[] args) 
{
    System.out.println("All Non-empty Subarrays");
    subArray(arr.length);
}
}
Output-
1 
1 2 
1 2 3 
1 2 3 4 
2 
2 3 
2 3 4 
3 
3 4 
4
This is not finding all subsets like (1,3)...
 
    
 
    