小编Pra*_*ant的帖子

如何打印整个String池?

我想打印整个字符串池,其中包含在垃圾收集之前String添加的文字和对象intern().

是否存在JDK隐含的此类操作方法?我们如何检查字符串池?

java string

11
推荐指数
2
解决办法
2907
查看次数

RowMapper如何成为匿名类

我正在阅读Spring in Action,发现像这样的人可以解释我们如何使用RowMapper作为Anonymous类,如果它是一个根据RowMapper文档的接口.

 public Employee getEmployeeById(long id) {
      return jdbcTemplate.queryForObject(
          "select id, firstname, lastname, salary " +
          "from employee where id=?",
          new RowMapper<Employee>() {
            public Employee mapRow(ResultSet rs,
                    int rowNum) throws SQLException {
              Employee employee = new Employee();
              employee.setId(rs.getLong("id"));
              employee.setFirstName(rs.getString("firstname"));

              employee.setLastName(rs.getString("lastname"));
              employee.setSalary(rs.getBigDecimal("salary"));
              return employee;
            }
          },
          id);
    }
Run Code Online (Sandbox Code Playgroud)

java spring

3
推荐指数
1
解决办法
5468
查看次数

它是多重继承吗?如果不是为什么?

public interface A {
    class Aclass {
        int constants = 100;
        public void display()
        {
            System.out.println("Inside A");
        }
    }
    public void display();

}
public interface B {
    class Bclass {
        int constants = 130;

        public void display() {
            System.out.println("Inside B");
        }
    }
    public void display();
}

public class MultipleInheritance implements A, B {

    @Override
    public void display() {
        A.Aclass a = new A.Aclass();
        System.out.println(a.constants);
        B.Bclass b = new B.Bclass();
        System.out.println(b.constants);
    }

    public static void main(String args[]) {

        new MultipleInheritance().display();
    } …
Run Code Online (Sandbox Code Playgroud)

java multiple-inheritance

3
推荐指数
1
解决办法
118
查看次数

标签 统计

java ×3

multiple-inheritance ×1

spring ×1

string ×1