title: Purpose of MongoCredential
body: <p>Was looking up a tutorial for connecting mongoDb with a java application and found that the were using MongoCredential to create credentials.
  What is the purpose of MongoCredential since all they do is print it to the console and is not used elsewhere.
  Also the code runs fine without the use of MongoCredential</p>
  
  <p>This is the code i refered to</p>
  
  <pre><code>import com.mongodb.client.MongoDatabase; 
  import com.mongodb.MongoClient; 
  import com.mongodb.MongoCredential;  
  
  public class ConnectToDB { 
  
  public static void main( String args[] ) {  
  
    // Creating a Mongo client 
    MongoClient mongo = new MongoClient( "localhost" , 27017 ); 
  
    // Creating Credentials 
    MongoCredential credential; 
    credential = MongoCredential.createCredential("sampleUser", "myDb", 
       "password".toCharArray()); 
    System.out.println("Connected to the database successfully");  
  
    // Accessing the database 
    MongoDatabase database = mongo.getDatabase("myDb"); 
    System.out.println("Credentials ::"+ credential);     
     } 
    }
  </code></pre>