A snippet kuliah karo mentor minangka bagéan saka kursus Universitas Codegym. Ndaftar kanggo kursus lengkap.
"Wah, wong wadon liyane manungsa! Nanging karo rambute ireng wektu iki. Apik banget!"
"Halo, jenengku Kim."
"Halo, jenengku Amigo!"
"Aku ngerti. Aku teka karo jeneng sampeyan. Diego ora bakal mikir sing munggah."
"Ayo bali menyang pelajaran. Aku bakal nggunakake tembung prasaja kanggo nerangake materi kanggo sampeyan."
"Oke."
"Aku pengin nambah sawetara tembung kanggo apa sing dikandhakake Profesor lan Rishi."
"Ing Jawa, sampeyan bisa nulis printah, nanging sampeyan uga bisa nambah komentar kanggo printah sing tengen ing kode. Compiler rampung nglirwakake komentar. Nalika program wis mbukak, kabeh komentar sing tilar. "
“Tulung paringi tuladha.
"Oh, mesthi:"
public class Home
{
public static void main(String[] args)
{
/*
Now we'll display the phrase 'Amigo Is The Best' on the screen
*/
System.out.print("Amigo ");
System.out.print("Is ");
System.out.print("The ");
System.out.print("Best");
}
}
"Kita nambahake komentar 'Saiki kita bakal nampilake frasa ...' Awal komentar dituduhake kanthi pasangan simbol ( /*
), lan pungkasan - dening ( */
). Nalika program dikompilasi, compiler ngilangi kabeh ing antarane simbol /*
lan */
. "
"Apa tegese aku bisa nulis apa wae sing dakkarepake?"
"Ya. Biasane, komentar ing kode babagan bagean kode sing angel dimangerteni. Sawetara komentar kalebu puluhan senar, asring ditulis sadurunge metode kanggo nggambarake nuansa cara kerjane."
"Ana siji cara liyane kanggo nambah komentar kanggo kode. Sampeyan bisa nggunakake rong garis miring maju ( //
).
public class Home
{
public static void main(String[] args)
{
System.out.print("Amigo ");
System.out.print("Is The "); // This is also a comment
System.out.print("Best");
}
}
"Ing kene, kode sing diwiwiti kanthi // lan nganti pungkasan baris kanthi // dianggep minangka komentar . Ing tembung liya, ora ana pasangan simbol kapindho sing digunakake kanggo 'ngrampungake komentar'."
"Oalah, sawetara komentar sing menarik banget."
// I'm not responsible of this code. They made me write it, against my will.
// Dear future me. Please forgive me.
// I can't even begin to express how sorry I am.
// If I see something like this once more, I'll have a complete mental breakdown at work.
// If this condition is ever satisfied,
// please inform me for a reward. Phone: xxx-xxx-xxx.
// Dear maintainer:
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
// total_hours_wasted_here = 42
// When I wrote this, only God and I understood what I was doing
// Now, God only knows
// Sometimes I believe compiler ignores all my comments.
// I dedicate all this code, all my work, to my wife, Darlene, who will
// have to support me and our three children and the dog once it gets
// released into the public.
// Drunk, fix later
// Magic. Do not touch
"Ya, sawetara komentar sing lucu banget."
"Iku kabeh kanggo dina iki."
"Iku pelajaran singkat nanging menarik. Matur nuwun, Kim."
GO TO FULL VERSION