class RecordDream(var user: String, var count: Int) {
val record get() = user + count
}
public final class RecordDream {
@NotNull
private String user;
private int count;
@NotNull
public final String getRecord() {
return this.user + this.count;
}
@NotNull
public final String getUser() {
return this.user;
}
public final void setUser(@NotNull String var1) {
Intrinsics.checkNotNullParameter(var1, "<set-?>");
this.user = var1;
}
public final int getCount() {
return this.count;
}
public final void setCount(int var1) {
this.count = var1;
}
public RecordDream(@NotNull String user, int count) {
Intrinsics.checkNotNullParameter(user, "user");
super();
this.user = user;
this.count = count;
}
}
생성자에 있는 파라미터의 get,set이 다 만들어 진 것을 볼 수 있다.
얘는 값을 읽고 변경 모두 가능하다는 말썸~!
class RecordDream1_1(val user: String, val count: Int) {
val record get() = user + count
}
public final class RecordDream1_1 {
@NotNull
private final String user;
private final int count;
@NotNull
public final String getRecord() {
return this.user + this.count;
}
@NotNull
public final String getUser() {
return this.user;
}
public final int getCount() {
return this.count;
}
public RecordDream1_1(@NotNull String user, int count) {
Intrinsics.checkNotNullParameter(user, "user");
super();
this.user = user;
this.count = count;
}
}
얘는 val로 선언을 했기 때문에 get만 만들어졌다잉
class RecordDream1_2(private val user: String, private val count: Int) {
val record get() = user + count
}
public final class RecordDream1_2 {
private final String user;
private final int count;
@NotNull
public final String getRecord() {
return this.user + this.count;
}
public RecordDream1_2(@NotNull String user, int count) {
Intrinsics.checkNotNullParameter(user, "user");
super();
this.user = user;
this.count = count;
}
}
얘는 private val로 만들어졌기에 변수의 값을 바꿀 수 있는 것은 없다잉
public final class RecordDream2 {
@NotNull
private final String innerUser;
private final int innerCount;
@NotNull
public final String getInnerUser() {
return this.innerUser;
}
public final int getInnerCount() {
return this.innerCount;
}
public RecordDream2(@NotNull String user, int count) {
Intrinsics.checkNotNullParameter(user, "user");
super();
this.innerUser = user;
this.innerCount = count;
}
}
결국 밖에서 값을 변경할 수 있게 하느냐 없느냐에 따라서 어캐쓸 지 달라진다는 것인가..?!!