Быстрое вступление
Исходный код хранится в файлах с расширением .kt (почему не .kot?).
В языке используется «кошачий принцип» — чем меньше печатаешь код, тем больше времени останется на сон.
Например, необязательно ставить точку с запятой в конце выражения. Так поступает JavaScript и многие новые языки программирования.
// и так сойдёт val x = 1 val y = 2
В Kotlin есть единственное место, где точка с запятой обязательна — в перечислении enum
Необязательно объявлять тип переменной, если из контекста понятно её предназначение. Если брать предыдущий пример, то по значению 1 можно догадаться, что переменная является типом Int.
Узнать тип переменной в студии можно через комбинацию клавиш Ctrl+Shift+P
Kotlin не делит типы на примитивные и их обёртки. Например, есть тип Int вместо int и Integer.
Можно сразу вызывать println вместо длинного System.out.println. Стандартная библиотека Kotlin включает в себя популярные методы Java для быстрого доступа.
Например, можно быстро получить содержимое файла с сервера через метод URL.readText():
// не вызывать в основном потоке! val address = "http://example.com" val someText = URL(address).readText()
Объявление переменных
В Java мы сначала указываем тип переменной, а потом её имя. В Kotlin немного не так. Сначала вы указываете ключевое слово val или var, затем имя переменной и по желанию можете указать тип переменной.
val kitty = "Васька" val age = 7 // необязательно, но укажем тип val weight: Int = 3 val catName: String = "Мурзик" val actionBar = supportActionBar // объект ActionBar в активности без new
Если вы не инициализируете переменную, то тип указать нужно обязательно.
val age: Int age = 7
Иногда тип указывать обязательно.
val a: Any = 12 val context: Context = activity
Ключевое слово val (от слова value) ссылается на неизменяемую переменную, что соответствует ключевому слову final в Java.
// Java final String name = "Васька"; // Kotlin val name = "Васька"
А часто используемое выражение в Java можно заменить на конструкцию с ключевым словом const (применимо только к базовым типам):
// Java public static final String CAT_TALK = "meow"; // Kotlin const val CAT_TALK = "meow"
Для обычных изменяемых переменных используется ключевое слово var (от слова variable).
Рекомендуется всегда использовать val, если это позволяет логика программы.
При этом нужно помнить, что хотя ссылка val неизменяема, сам объект может быть изменяемым:
val cats = arrayListOf("Васька") cats.add("Барсик")
При использовании var вы можете не указывать тип переменной, но это не значит, что вы можете использовать его не по назначению, это вам не PHP.
var answer = 42 // так нельзя answer = "нет ответа"
Возникает вопрос, а в чём разница между val и const? В некоторых случаях поведение будем одинаковым, но есть разница в подходе. Мы можем использовать const для константы на этапе компиляции, а для val мы можем присвоить неизменяемое значение на этапе рантайма.
const val catName = "Мурзик" // можно val catName = "Мурзик" // тоже можно const val catName = getCompanyName() // нельзя, нужно сразу присвоить значение без вычислений val catName = getCompanyName() // а так можно
Когда и где использовать val и const? Рассмотрим пример.
// какой-то класс MyClass < companion object < const val FILE_EXTENSION = ".png" val FILENAME: String get() = "img_" + System.currentTimeMillis() + FILE_EXTENSION >>
Расширение класса можно считать константой. А имя файла вычисляется на основе времени и его нельзя использовать как константу.
Ключевое слово inline
Ещё одно новое ключевое слово в Kotlin.
Псевдоним для импорта
Чтобы не путаться с именами классов из разных пакетов, можно присвоить новый псевдоним.
import android.os.Bundle import ru.alexanderklimov.cat.Bundle as CatBundle fun getBundle()
typealias
Псевдоним типа позволяет определить для существующего типа альтернативное имя, которое может использоваться в коде. Если в вашем коде используется функциональный тип, например такой, как (Double) -> Double, — вы сможете определить псевдоним, который будет использоваться вместо этого типа, чтобы ваш код лучше читался. Псевдонимы типов определяются ключевым словом typealias.
typealias DoubleConversion = (Double) -> Double
При помощи typealias можно определять альтернативные имена для любых типов, не только функциональных. Например, следующее определение typealias CatArray = Array позволяет обращаться к типу по имени CatArray вместо Array .
Исключения
Создадим собственное исключение.
class CustomException(message:String): Exception(message)
Теперь можем кинуть созданное исключение в своём коде в нужном месте.
throw CustomException("Threw custom exception")
Kotlin Series — val vs var Difference (Android Kotlin)
T his Story is from the Kotlin- Series, In which we will learn What is the actual difference between val and var.
Basically, val and var both are used to declare a variable. var is like a general variable and can be assigned multiple times and is known as the mutable variable in Kotlin. Whereas val is a constant variable and can not be assigned multiple times and can be Initialized only single time and is known as the immutable variable in Kotlin.
Let me show you with an Example:
Val:
private val adapter: HomeAdapter? = null
After the Initialized It will throw me an error like “Val can not be reassigned”
private var adapter: HomeAdapter? = null
After the Initialized It will not throw me an error because var is a mutable and it can be assigned multiple times.
If you want to learn more related to Kotlin then check it out the below link:
What is the difference between «var» and «val» in Kotlin?
In Kotlin, we can declare a variable using two different keywords: one is var and the other one is val. In this article, we will take an example and demonstrate how these declarations are different from each other.
| Attribute | var | val |
|---|---|---|
| Declaration | var varName=»hello World» | val sName = «tutorialspoint.com» |
| Immutability | Mutable | Immutable |
| No. of times a variable can be assigned | Can be assigned multiple times. | Cannot be assigned multiple times. |
| Reassigned | Can be reassigned | Cannot be reassigned |
Example
In the following example, we will see how we can declare two different variables using «val» and «var». We will also see that the variable declared using ‘var’ can be changed, while the variable declared using ‘val’ cannot be reassigned as it will throw an error at runtime with the error message «Val cannot be reassigned.»
val sName = "tutorialspoint"; var varName = "hello World" fun main() < println("Example of val--->"+sName); println("Example of Var--->"+varName); // Variable declared by var is mutable varName = "new value"; println("New value of the variable declared using Var: " +varName); >
Output
It will generate the following output −
Example of val--->tutorialspoint Example of Var--->hello World New value of the variable declared using Var: new value
Example
Now, let’s try to change the value of the variable declared using val −
val sName = "tutorialspoint"; var varName = "hello World" fun main() < println("Example of val--->"+sName); println("Example of Var--->"+varName); // Variable declared by val is not mutable sName = "new value"; println("New value of the variable declared using Var: " +sName); >
Output
It will throw an error at runtime −
main.kt:9:5: error: val cannot be reassigned sName = "new value"; ^
What is the difference between var and val in Kotlin?
What is the difference between var and val in Kotlin? I have gone through this link: KotlinLang: Properties and Fields As stated on this link:
The full syntax of a read-only property declaration differs from a mutable one in two ways: it starts with val instead of var and does not allow a setter.
But just before there is an example which uses a setter.
fun copyAddress(address: Address): Address < val result = Address() // there's no 'new' keyword in Kotlin result.name = address.name // accessors are called result.street = address.street // . return result >
What is the exact difference between var and val ? Why do we need both? This is not a duplicate of Variables in Kotlin, differences with Java: ‘var’ vs. ‘val’? as I am asking about the doubt related to the particular example in the documentation and not just in general.
1,582 2 2 gold badges 12 12 silver badges 30 30 bronze badges
asked May 26, 2017 at 11:11
Akshar Patel Akshar Patel
9,048 6 6 gold badges 35 35 silver badges 50 50 bronze badges
result can not be changed to refer to a different instance of Address , but the instance it refers to can still be modified. The same would be true in Java if you had a final Address result = new Address();
May 26, 2017 at 11:13
refer this android-kotlin-beginners.blogspot.in/2018/02/…
Feb 1, 2018 at 16:14
Came here for the answer because the Kotlin website that first describes variables was too dumb to mention it there: kotlinlang.org/docs/reference/basic-syntax.html
Nov 14, 2018 at 17:43
32 Answers 32
In your code result is not changing, its var properties are changing. Refer comments below:
fun copyAddress(address: Address): Address < val result = Address() // result is read only result.name = address.name // but not their properties. result.street = address.street // . return result >
val is same as the final modifier in java. As you should probably know that we can not assign to a final variable again but can change its properties.
85k 38 38 gold badges 185 185 silver badges 227 227 bronze badges
answered May 26, 2017 at 11:15
Sachin Chandil Sachin Chandil
17.3k 8 8 gold badges 47 47 silver badges 65 65 bronze badges
val and var in function and classes or in primary constructor have different meaning?
– user6685522
May 27, 2017 at 14:45
@Nothing No, everywhere its same.
May 27, 2017 at 14:47
But when I declare variable with var in the class it required initialization because of it declare the property. But in the function it not required initialization why?
– user6685522
May 27, 2017 at 16:59
Because when class loads into the memory, its properties also gets evaluated. But in function variables are evaluated when function code is executed.
May 27, 2017 at 17:03
Its mean inside the function or inside the class both keyword val and var are used to declare the properties? not variable?
– user6685522
May 27, 2017 at 17:20
val and var both are used to declare a variable.
var is like general variable and it’s known as a mutable variable in kotlin and can be assigned multiple times.
val is like Final variable and it’s known as immutable in kotlin and can be initialized only single time.
For more information what is val and var please see below link
1 1 1 silver badge
answered Jun 5, 2017 at 4:30
Patel Pinkal Patel Pinkal
9,044 5 5 gold badges 29 29 silver badges 50 50 bronze badges
variables defined with var are mutable(Read and Write)
variables defined with val are immutable(Read only)
Kotlin can remove findViewById and reduce code for setOnClickListener in android studio. For full reference: Kotlin awesome features
value of mutable variables can be changed at anytime, while you can not change value of immutable variables.
where should I use var and where val ?
use var where value is changing frequently. For example while getting location of android device
var integerVariable : Int? = null
use val where there is no change in value in whole class. For example you want set textview or button’s text programmatically.
val stringVariables : String = "Button's Constant or final Text"
answered Jun 7, 2017 at 17:54
user6435056 user6435056
717 6 6 silver badges 5 5 bronze badges
«Kotlin can remove findViewById and reduce code for setOnClickListener in android studio. For full reference: Kotlin awesome features» How is this relevant to the question asked?
Dec 4, 2017 at 12:25
val variables are not necessarily immutable. They are final — only the reference is immutable — but if the object stored in the val is mutable, the object is mutable regardless of whether it is assigned via val or var.
Jun 29, 2018 at 21:59
i don’t see the point of introducing two new keywords while it could be done much better understandably previously in Java
Dec 8, 2018 at 21:45
val use to declare final variable. Characteristics of val variables

- Must be initialized
- value can not be changed or reassign
var is as a general variable
- We can initialize later by using lateinit modifier [ lateinit also use for global variable we can not use it for local variable]
- value can be changed or reassign but not in global scope

val in kotlin is like final keyword in java
answered Aug 23, 2017 at 13:47
user4696837 user4696837
val is immutable and var is mutable in Kotlin.
answered Jun 4, 2017 at 7:58
Samir Mangroliya Samir Mangroliya
40k 16 16 gold badges 117 117 silver badges 134 134 bronze badges
Retread of stackoverflow.com/a/44260269
Mar 28 at 5:57
You can easily think it as:
var is used for setter (value will change).
val is used for getter (read-only, value won’t change).
answered May 28, 2017 at 2:07
159 5 5 bronze badges
+----------------+-----------------------------+---------------------------+ | | val | var | +----------------+-----------------------------+---------------------------+ | Reference type | Immutable(once initialized | Mutable(can able to change| | | can't be reassigned) | value) | +----------------+-----------------------------+---------------------------+ | Example | val n = 20 | var n = 20 | +----------------+-----------------------------+---------------------------+ | In Java | final int n = 20; | int n = 20; | +----------------+-----------------------------+---------------------------+
answered Mar 31, 2018 at 15:05
Joby Wilson Mathews Joby Wilson Mathews
10.6k 6 6 gold badges 55 55 silver badges 53 53 bronze badges
Simply, var (mutable) and val (immutable values like in Java (final modifier))
var x:Int=3 x *= x //gives compilation error (val cannot be re-assigned) val y: Int = 6 y*=y
answered May 30, 2017 at 10:53
1,377 16 16 silver badges 19 19 bronze badges
If we declare variable using val then it will be read-only variable. We cannot change it’s value. It’s like final variable of Java. It’s immutable .
But if we declare variable using var then it will be a variable which we can read or write. We can change it’s value. It’s mutable .
data class Name(val firstName: String, var lastName: String) fun printName(name: Name): Name < val myName = Name("Avijit", "Karmakar") // myName variable is read only // firstName variable is read-only. //You will get a compile time error. Val cannot be reassigned. myName.firstName = myName.firstName // lastName variable can be read and write as it's a var. myName.lastName = myName.lastName return myName >
val cannot be initialized lately by the keyword lateinit but non-primitive var can be initialized lately by the keyword lateinit .
answered May 26, 2017 at 17:35
Avijit Karmakar Avijit Karmakar
8,978 6 6 gold badges 45 45 silver badges 60 60 bronze badges
val and var in function and classes or in primary constructor have different meaning?
– user6685522
May 27, 2017 at 14:46
- var = variable, so it can change
- val = value, so it can not change.
2,722 3 3 gold badges 33 33 silver badges 56 56 bronze badges
answered Dec 27, 2018 at 4:23
Bharat Sonawane Bharat Sonawane
162 3 3 silver badges 10 10 bronze badges
In Kotlin val is a read-only property and it can be accessed by a getter only. val is immutable.
val example :
val piNumber: Double = 3.1415926 get() = field
However, var is a read-and-write property, so it can be accessed not only by a getter but a setter as well. var is mutable.
var example :
var gravity: Double = 9.8 get() = field set(value)
If you try to change an immutable val , IDE will show you error :
fun main() < piNumber = 3.14 // ERROR println(piNumber) >// RESULT: Val cannot be reassigned
But a mutable var can be changed :
fun main() < gravity = 0.0 println(gravity) >// RESULT: 0.0
answered Jan 14, 2019 at 13:48
50k 18 18 gold badges 142 142 silver badges 220 220 bronze badges
Comparing val to a final is wrong!
var s are mutable val s are read only; Yes val cannot be reassigned just like final variables from Java but they can return a different value over time, so saying that they are immutable is kind of wrong;
Consider the following
var a = 10 a = 11 //Works as expected
val b = 10 b = 11 //Cannot Reassign, as expected
Now consider the following for val s
val d get() = System.currentTimeMillis() println(d) //Wait a millisecond println(d) //Surprise!, the value of d will be different both times
Hence, vars can correspond to nonfinal variables from Java, but val aren’t exactly final variables either;
Although there are const in kotlin which can be like final , as they are compile time constants and don’t have a custom getter, but they only work on primitives
answered Jul 23, 2020 at 13:13
Vishal Ambre Vishal Ambre
403 4 4 silver badges 9 9 bronze badges
Interesting example. I never thought of using a val in this way: since I try to use Kotlin as immutably as possible, it never occurred to me to even try using a stateful getter for a property marked val .
Jan 16 at 8:22
var is like a general variable and can be assigned multiple times and is known as the mutable variable in Kotlin. Whereas val is a constant variable and can not be assigned multiple times and can be Initialized only single time and is known as the immutable variable in Kotlin.
Val: Assigned once (Read only)
Var: Mutable
example : define a variable to store userId value:
val userId = 1
if we are trying to change the variable userId you will get Error message
userId = 2 error: val cannot be reassigned // Error message!
Let’s create a new variable to store the name of the user:
var userName = "Nav"
if you want to reassign the value of userName you can easily do this because var is mutable
userName = "Van"
and now the value of userName is «Van».
answered Oct 5, 2021 at 2:58
Naveen kumar Naveen kumar
111 1 1 silver badge 4 4 bronze badges
constant variable is an oxymoron. «read-only» or «immutable» are better words to describe val
Mar 22, 2022 at 17:58
Value to val variable can be assigned only once.
val address = Address("Bangalore","India") address = Address("Delhi","India") // Error, Reassigning is not possible with val
Though you can’t reassign the value but you can certainly modify the properties of the object.
//Given that city and country are not val address.setCity("Delhi") address.setCountry("India")
That means you can’t change the object reference to which the variable is pointing but the underlying properties of that variable can be changed.
Value to var variable can be reassigned as many times as you want.
var address = Address("Bangalore","India") address = Address("Delhi","India") // No Error , Reassigning possible.
Obviously, It’s underlying properties can be changed as long as they are not declared val.
//Given that city and country are not val address.setCity("Delhi") address.setCountry("India")
answered Oct 25, 2018 at 10:33
Saurabh Padwekar Saurabh Padwekar
3,918 1 1 gold badge 31 31 silver badges 37 37 bronze badges
Do you need to change a variable or set it permanently?
- A good example if it is something like val pi5places = 3.14159 you would set it as val . Is there a possibility that you need to change that variable now or later, then you would set it as var.
- For example : The color of a car, can be var colorCar = green . Later you can change that colorCar = blue , where as a val , you can not.
- Responses here regarding mutable and immutable is fine, but may be scary if these terms are not well known or just getting into learning how to program.
user10828639
answered Aug 16, 2017 at 18:06
41 2 2 bronze badges
Both variables are used as initialising
- val like a constant variable, It can be readable, and the properties of a val can be modified.
- var just like a mutable variable. you can change the value at any time.
answered Apr 19, 2018 at 5:45
Nikhil Katekhaye Nikhil Katekhaye
2,374 1 1 gold badge 18 18 silver badges 19 19 bronze badges
val like constant variable, itself cannot be changed, only can be read, but the properties of a val can be modified; var just like mutant variable in other programming languages.
answered Feb 10, 2018 at 7:17
109 1 1 gold badge 1 1 silver badge 4 4 bronze badges
Both, val and var can be used for declaring variables (local and class properties).
Local variables:
- val declares read-only variables that can only be assigned once, but cannot be reassigned.
val readonlyString = “hello” readonlyString = “c u” // Not allowed for `val`
- var declares reassignable variables as you know them from Java (the keyword will be introduced in Java 10, “local variable type inference”).
var reasignableString = “hello” reasignableString = “c u” // OK
It is always preferable to use val . Try to avoid var as often as possible!
Class properties:
Both keywords are also used in order to define properties inside classes. As an example, have a look at the following data class :
data class Person (val name: String, var age: Int)
The Person contains two fields, one of which is readonly ( name ). The age , on the other hand, may be reassigned after class instantiation, via the provided setter . Note that name won’t have a corresponding setter method.
answered Jan 4, 2018 at 12:47
77.3k 17 17 gold badges 168 168 silver badges 196 196 bronze badges
Var means Variable-If you stored any object using ‘var’ it could change in time.
fun main(args: Array) < var a=12 var b=13 var c=12 a=c+b **//new object 25** print(a) >
Val means value-It’s like a ‘constant’ in java .if you stored any object using ‘val’ it could not change in time.
fun main(args: Array) < val a=12 var b=13 var c=12 a=c+b **//You can't assign like that.it's an error.** print(a) >
answered May 10, 2018 at 5:30
11 2 2 bronze badges
In short, val variable is final (not mutable) or constant value that won’t be changed in future and var variable (mutable) can be changed in future.
class DeliveryOrderEvent(val d : Delivery) // Only getter
See the above code. It is a model class, will be used for data passing. I have set val before the variable because this variable was used to get the data.
class DeliveryOrderEvent(var d : Delivery) // setter and getter is fine here. No error
Also, if you need to set data later you need to use var keyword before a variable, if you only need to get the value once then use val keyword
answered Aug 26, 2018 at 6:17
2,526 27 27 silver badges 27 27 bronze badges
Var is a mutable variable. It is a variable that can be changed to another value. It’s similar to declaring a variable in Java.
Val is a read-only thing. It’s similar to final in java. A val must be initialized when it is created. This is because it cannot be changed after it is created.
var test1Var = "Hello" println(test1Var) test1Var = "GoodBye" println(test1Var) val test2Val = "FinalTestForVal"; println(test2Val);
answered Feb 13, 2022 at 2:19
Marcus Thornton Marcus Thornton
6,013 7 7 gold badges 48 48 silver badges 50 50 bronze badges
var:
- Declare a variable whose value can be changed at any time.
- This is commonly used for declaring a variable with global scope.
- It is re-assign able.
- It is not re-declarable in its scope.
val:
- It is used to define constants at run time. A major difference from const.
- It is not re-assign able in its scope.
- It is not re-declarable in its scope.
- The declaration is block function scoped.
answered Apr 22 at 7:51
Anand Gaur Anand Gaur
225 2 2 silver badges 10 10 bronze badges
val (from value): Immutable reference. A variable declared with val can’t be reassigned after it’s initialized. It corresponds to a final variable in Java.
var (from variable): Mutable reference. The value of such a variable can be changed. This declaration corresponds to a regular (non-final) Java variable.
answered Jan 6, 2018 at 9:45
Gulzar Bhat Gulzar Bhat
1,275 11 11 silver badges 13 13 bronze badges
VAR is used for creating those variable whose value will change over the course of time in your application. It is same as VAR of swift, whereas VAL is used for creating those variable whose value will not change over the course of time in your application.It is same as LET of swift.
answered May 29, 2018 at 14:05
Ashutosh Shukla Ashutosh Shukla
358 5 5 silver badges 14 14 bronze badges
val — Immutable(once initialized can’t be reassigned)
var — Mutable(can able to change value)
in Kotlin — val n = 20 & var n = 20
In Java — final int n = 20; & int n = 20;
answered Jun 6, 2018 at 7:56
NAP-Developer NAP-Developer
3,716 1 1 gold badge 25 25 silver badges 39 39 bronze badges
In Kotlin we use var to declare a variable. It is mutable. We can change, reassign variables. Example,
fun main(args : Array) < var x = 10 println(x) x = 100 // vars can reassign. println(x) >
We use val to declare constants. They are immutable. Unable to change, reassign vals. val is something similar to final variables in java. Example,
fun main(args : Array) < val y = 10 println(y) y = 100 // vals can't reassign (COMPILE ERROR!). println(y) >
answered Jun 25, 2018 at 8:21
Osusara Kammalawatta Osusara Kammalawatta
133 9 9 bronze badges
I get the exact answer from de-compiling Kotlin to Java.
If you do this in Kotlin:
data class UsingVarAndNoInit(var name: String) data class UsingValAndNoInit(val name: String)
You will get UsingVarAndNoInit:
package classesiiiandiiiobjects.dataiiiclasses.p04variiiandiiival; import kotlin.jvm.internal.Intrinsics; import org.jetbrains.annotations.NotNull; public final class UsingVarAndNoInit < @NotNull private String name; @NotNull public final String getName() < return this.name; >public final void setName(@NotNull String string) < Intrinsics.checkParameterIsNotNull((Object) string, (String) ""); this.name = string; > public UsingVarAndNoInit(@NotNull String name) < Intrinsics.checkParameterIsNotNull((Object) name, (String) "name"); this.name = name; >@NotNull public final String component1() < return this.name; >@NotNull public final UsingVarAndNoInit copy(@NotNull String name) < Intrinsics.checkParameterIsNotNull((Object) name, (String) "name"); return new UsingVarAndNoInit(name); >@NotNull public static /* bridge */ /* synthetic */ UsingVarAndNoInit copy$default( UsingVarAndNoInit usingVarAndNoInit, String string, int n, Object object) < if ((n & 1) != 0) < string = usingVarAndNoInit.name; >return usingVarAndNoInit.copy(string); > public String toString() < return "UsingVarAndNoInit(name=" + this.name + ")"; >public int hashCode() < String string = this.name; return string != null ? string.hashCode() : 0; >public boolean equals(Object object) < block3: < block2: < if (this == object) break block2; if (!(object instanceof UsingVarAndNoInit)) break block3; UsingVarAndNoInit usingVarAndNoInit = (UsingVarAndNoInit) object; if (!Intrinsics.areEqual((Object) this.name, (Object) usingVarAndNoInit.name)) break block3; >return true; > return false; > >
You will also get UsingValAndNoInit:
package classesiiiandiiiobjects.dataiiiclasses.p04variiiandiiival; import kotlin.jvm.internal.Intrinsics; import org.jetbrains.annotations.NotNull; public final class UsingValAndNoInit < @NotNull private final String name; @NotNull public final String getName() < return this.name; >public UsingValAndNoInit(@NotNull String name) < Intrinsics.checkParameterIsNotNull((Object) name, (String) "name"); this.name = name; >@NotNull public final String component1() < return this.name; >@NotNull public final UsingValAndNoInit copy(@NotNull String name) < Intrinsics.checkParameterIsNotNull((Object) name, (String) "name"); return new UsingValAndNoInit(name); >@NotNull public static /* bridge */ /* synthetic */ UsingValAndNoInit copy$default( UsingValAndNoInit usingValAndNoInit, String string, int n, Object object) < if ((n & 1) != 0) < string = usingValAndNoInit.name; >return usingValAndNoInit.copy(string); > public String toString() < return "UsingValAndNoInit(name=" + this.name + ")"; >public int hashCode() < String string = this.name; return string != null ? string.hashCode() : 0; >public boolean equals(Object object) < block3: < block2: < if (this == object) break block2; if (!(object instanceof UsingValAndNoInit)) break block3; UsingValAndNoInit usingValAndNoInit = (UsingValAndNoInit) object; if (!Intrinsics.areEqual((Object) this.name, (Object) usingValAndNoInit.name)) break block3; >return true; > return false; > >