java 如何Mapgetter和setter

cbjzeqam  于 2022-12-02  发布在  Java
关注(0)|答案(1)|浏览(109)

显示返回值的方法从未使用的错误消息。

public Long getId(){ return id; }
public void setId(Long id){ this.id = id; }

public  void  setQueue(String queue){ this.queue = queue;}
public String  getQueue() { return queue; }

public Number getAnswered(){ return answered; }
public  void setAnswered(Number answered){ this.answered = answered; }

//how to map and where to reffer this getters and setters

我不熟悉春 Boot

ctehm74n

ctehm74n1#

您的类中必须包含此对象,可以是private/protected/public/default,也可以是none

private Long id;
private String queue;
private Number answered;

要使用这些方法,请创建此类的新对象并调用方法,例如,您有一个名为A的类,它具有上述属性

class A{
   private Long id;
   private String queue;
   private Number answered;
}

在其他地方创建类A的新示例并调用方法

A instanceOfA = new A();
A.setId(1);
System.out.println(A.getId()); // This will print number 1 to the screen

相关问题