1.equals方法比较两个字符串是否相等
private SqlStringServiceImpl getSqlStringService (String type) throws Exception {
if (type.equals(“Hive”)){
return new HiveSqlStringServiceImpl();
}
else if (type.equals(“Mysql”)){
return new MysqlSqlStringServiceImpl();
}
else {
throw new Exception(“失败”);
}
}
2.equalsIgnoreCase方法比较两个字符串是否相等并且忽略大小写
private SqlStringServiceImpl getSqlStringService (String type) throws Exception {
if (type.equalsIgnoreCase(“Hive”)){
return new HiveSqlStringServiceImpl();
}
else if (type.equalsIgnoreCase(“Mysql”)){
return new MysqlSqlStringServiceImpl();
}
else {
throw new Exception(“失败”);
}
}