0

This is a piece of code:

abstract class Object1
{
    protected Medium medium;

    public Object1(Medium medium)
    {
        this.medium = medium;
    }
}

private SpecificObject1 _name1;

public SpecificObject1 Object1
        {
            set { _name1 = value; }
        }

The question is, how to implement it in Java? In particular, I am asking for:

set { _name1 = value; }

How to do it in Java?

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
  • 2
    In Java you have to write the whole method. `public void setName1( SpecificObject1 o ){ _name1 = o; }` – markspace Apr 16 '22 at 17:49
  • 1
    this question was answered here https://stackoverflow.com/questions/2963243/does-java-have-something-similar-to-c-sharp-properties – braian azcune Apr 16 '22 at 17:59

1 Answers1

0
private String value;

public void setValue(String s) {
    this.value = s;
}
Federico klez Culloca
  • 24,336
  • 15
  • 57
  • 93
Raees_21
  • 44
  • 5