我发现很难理解递归

时间:2016-10-23 03:24:39

标签: recursion

我发现很难理解递归。任何人都可以通过cout<<电话print3来说明 void print3(char a[],int i) { if(a[i] == '\0') { return; } else { cout<<print3(a,i+1); } } 的错误。

static String user = "guest";
static String database = "VsJogger";
static char[] password = {'g','u','e','s','t'};
public static void main(String[] args) {
    MongoCredential credential = MongoCredential.createCredential(user,
                                                                  database,
                                                                  password);

    MongoClientURI uri = new MongoClientURI("mongodb://"+user+":"
            +String.valueOf(password)
            +"@localhost/?authSource="+database);

   try{

     // To connect to mongodb server
     MongoClient mongoClient = new MongoClient( uri);


     // Now connect to your databases
     MongoDatabase db = mongoClient.getDatabase("VsJogger");
     System.out.println("Connect to database successfully");
     MongoCollection coll = db.getCollection("Jog");
     MongoCursor<Document> cursor = coll.find().iterator();

     int i = 1;
     while (cursor.hasNext()) { 
        System.out.println("Inserted Document: "+i); 
        System.out.println(cursor.next()); 
        i++;
     }


  }catch(Exception e){
     System.err.println( e.getClass().getName() + ": " + e.getMessage() );
  }

0 个答案:

没有答案