﻿# V6091\. Suspicious getter/setter implementation\. The 'A' field should probably be returned/assigned instead\.

The analyzer has detected a getter/setter that accesses a field different from the one mentioned in the name\.

Such errors usually result from inattention or inaccurate use of autocomplete or copy\-paste\. 

Consider the following example:

```cpp
public class Vector2i
{
  private int x;
  private int y;

  public void setX(int x)
  {
    this.x = x;
  }
  public int getX()
  {
    return x;
  }

  public void setY(int y)
  {
    this.y = y;
  }
  public int getY()
  {
    return x;              // <=
  }
}
```

Fixed code:

```cpp
public class Vector2i
{
  private int x;
  private int y;

  public void setX(int x)
  {
    this.x = x;
  }
  public int getX()
  {
    return x;
  }

  public void setY(int y)
  {
    this.y = y;
  }
  public int getY()
  {
    return y;
  }
}
```

To implement methods like that, it is better to use the means provided by the IDE or code generation provided by the [Lombok](https://projectlombok.org/) library\.