A snippet kuliah karo mentor minangka bagéan saka kursus Universitas Codegym. Ndaftar kanggo kursus lengkap.

"Halo, Amigo."

"Halo, Eleanor Carrey."

"Sebut wae aku Ellie. Ora perlu formal banget."

"Oke, Ellie."

"Aku yakin kanthi bantuanku, sampeyan bakal dadi salah siji sing paling apik. Aku duwe akeh pengalaman latihan wong anyar. Tetep karo aku, lan kabeh bakal apik. Ayo, ayo miwiti."

"Ana rong jinis utama ing Jawa : String lan int . Kita nyimpen strings/teks ing String, lan integers (nomer wutuh) ing int. Kanggo mratelakake variabel anyar, sampeyan kudu nemtokake jinis lan jeneng sawijining. Jeneng ora bisa dadi padha karo jeneng variabel lan/utawa fungsi liyane."

Tuladha 1, kode: Katrangan
``String s;``
Variabel anyar `s`diumumake. Bisa nyimpen teks.
``int i;``
Variabel anyar `i`, diumumake. Bisa nyimpen integer.

"Sampeyan bisa nemtokake nilai kanggo variabel nalika sampeyan ngumumake."

Tuladha 2, kode: Katrangan
``String s = "Ellie";``
Variabel `s`nyimpen string `"Ellie"`.
``int i = 5;``
Variabel `i`nyimpen nomer 5.

"Kanggo nemtokake nilai anyar kanggo variabel, kita nggunakake tandha `=`. Iki uga disebut 'operator penugasan' . Assignment tegese kanggo nyelehake menyang variabel nilai saka variabel liyane utawa siji diitung saka sawetara variabel. "

Tuladha 3, kode: Katrangan
``int a = 5;``
Variabel `a`nyimpen nilai 5.
``int b = 6;``
Variabel `b`nyimpen nilai 6.
``int c = a + b;``
Variabel `c`nyimpen nilai 11.

"Nilai variabel bisa digunakake kanggo ngitung nilai anyar sing bakal ngganti sing lawas."

Tuladha 4, kode: Katrangan
``int a = 2;``
Saiki `a`padha karo 2
``int b = 3;``
Saiki `b`padha karo 3
``a = a + b;``
Saiki `a`padha karo 5
``b = b + 1;``
Saiki `b`padha karo 4

"Sampeyan bisa nggabungake string karo `+`tandha:"

Tuladha 5, kode: Katrangan
``````String s1 = "Rain";
String s2 = "In";
String s3 = s1 + s2 + "Spain";``````
Variabel `s3`nyimpen senar`"RainInSpain"`

"Kadhangkala, string sing dumadi saka siji utawa luwih spasi bisa migunani:"

Tuladha 6, kode: Katrangan
``````String s1 = "My favorite movie is";
String s2 = "Route";
int roadNumber = 66;
String text = s1 + " " + s2 + " " + roadNumber;``````
`text`toko`"My favorite movie is Route 66"`

"Ayo deleng carane nampilake teks lan variabel ing layar:"

``System.out.println("A man's gotta do what a man's gotta do");``
``````String s = "A man's gotta do what a man's gotta do";