Tuesday, 16 February 2016

Write a java program to Remove duplicate characters in a given String ?

Write a java program to Remove duplicate characters in a given String ?

import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

public class RemoveDuplicateCharacters {
      public String removeDuplicates(String input) {
            Set<Character> set = new LinkedHashSet<>();
            for (int i = 0; i < input.length(); i++) {
                  set.add(input.charAt(i));
            }
            StringBuilder sb = new StringBuilder();
            for (Character c : set) {
                  sb.append(c);
            }
            return sb.toString();
      }
      public static void main(String[] args) {
            RemoveDuplicateCharacters rd = new RemoveDuplicateCharacters();
            Scanner scanner = new Scanner(System.in);
            System.out.println("Please enter a String:");
            String input = scanner.next();
            System.out.println("RESULT IS : "+rd.removeDuplicates(input));
      }
}

Ouput:
Please enter a String:
mmmaaadddhhhuuu

RESULT IS : madhu 

Monday, 15 February 2016

What is Differences between Hadoop and RDBMS ?


Diffrences Between Hadoop And RDBMS





RDBMS

HADOOP
Data size
Gigabytes
Petabytes
Access
Interactive and batch
Batch
Updates
Read and write many
Write and read many
Structure
Static schema
Dynamic schema
Integrity
High Normalisation
Low Normalisation
Scalling
Non Linear
Linear


What is differences between Apache Hive and RDBMS ?



What is differences between Apache Hive and RDBMS ?
                      
                              Hive

                           
                              RDBS
SQL  Interface

SQL  Interface

Focus  on  analytics

May  focus  on  online  or  analytics.

No  transactions.

Transactions  usually  supported.

Partition  adds,  no  random  INSERTs. InPlace  updates  not  natively  supported  
(but   are  possible).

Random  INSERT  and  UPDATE  supported.  

Distributed  processing  via  map/reduce.

Distributed  processing  varies  by  vendor  
(if  available).

Scales  to  hundreds  of  nodes

Seldom  scale  beyond  20  nodes
Built  for  commodity  hardware
Often  built  on  proprietary  hardware   (especially  when  scaling  out).

Low  cost  per  peta byte.

What’s  a  peta byte? J



Sunday, 14 February 2016

Write a Java Program Without using reverse function?

Write a Java Program Without using reverse Funtion?

import java.util.Scanner;

public class ReverseStringWithoutReverseFunction {

       public static String reverse(String str) {
              StringBuilder sb = new StringBuilder();
              char[] string = str.toCharArray();
              for (int i = string.length - 1; i >= 0; i--) {
                     sb.append(string[i]);
              }
              System.out.println(sb.toString());
              return sb.toString();
       }

       public static void main(String[] args) {
              Scanner keyboard = new Scanner(System.in);
              System.out.println("Enter a String:");
              String input = keyboard.next();
              reverse(input);
       }

}