eclipse添加注释的快捷方法
1.多个单行注释 :
选中要添加的代码,按 Ctrl+/ 添加完毕后如图
// @Test // public void connectMongodb() { // try { // // 连接到 mongodb 服务 // MongoClient mongoClient = new MongoClient("localhost", 27017); // // 连接到数据库 // MongoDatabase db = mongoClient.getDatabase("test"); // System.out.println("Connect to database successfully"); // db.createCollection("test"); // System.out.println("集合创建成功"); // } catch (Exception e) { // System.err.println(e.getClass().getName() + ": " + e.getMessage()); // } // }
2.Javadoc 注释:
在方法名和类之前 按Alt+Shift+J 可以添加
/** * @author Administrator * @date 2017-07-28 * */ public class TestMistake { }
3.多行注释 :
选中要注释的代码,Ctrl+Shift+/,去除注释的快捷键是Ctrl+Shift+\
/* @Test public void connectMongodb() { try { // 连接到 mongodb 服务 MongoClient mongoClient = new MongoClient("localhost", 27017); // 连接到数据库 MongoDatabase db = mongoClient.getDatabase("test"); System.out.println("Connect to database successfully"); db.createCollection("test"); System.out.println("集合创建成功"); } catch (Exception e) { System.err.println(e.getClass().getName() + ": " + e.getMessage()); } }*/
版权声明:本文为jianpanaq原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。