PythonPython · Chapterبەش 12 · Lectureوانە 12.3

Python Next to JavaPython لە تەنیشت Javaـەوە

Read Java by comparing it with the Python you know: Hello World and the class with main, javac and the JVM, declared types and compile-time errors, comments, if/else if, for/while/do-while, methods, arrays and ArrayList — the course report's examples corrected and run — then comparison tables on syntax, speed and uses, the course's other tracks (MATLAB today, perhaps Java and C# later), and a summary of the whole Python track.

Java بخوێنەرەوە بە بەراوردکردنی لەگەڵ ئەو Pythonـەی دەیزانیت: ⁦Hello World⁩ و لەگەڵ main، javac و JVM، جۆری ناسێنراو و ، ، ⁦if/else if⁩، ⁦for/while/do-while⁩، ، و ArrayList — نموونەکانی ڕاپۆرتی کۆرسەکە ڕاستکراو و جێبەجێکراو — پاشان خشتەی بەراورد بۆ ، خێرایی و بەکارهێنان، ڕێڕەوەکانی تری کۆرسەکە (MATLAB ئەمڕۆ، لەوانەیە Java و ⁦C#⁩ دواتر) و پوختەی هەموو ڕێڕەوی .

30 min read31 خولەک خوێندنەوە · 28 stepsهەنگاو

What you will learnچی فێر دەبیت

  • Read a small Java program: the class, the main method, declarations, braces and semicolons.
  • Explain how javac and the JVM run Java, and how Python runs a file, in today's bytecode model.
  • Translate variables, decisions, loops, functions and lists between Python and Java.
  • Tell compile-time errors from runtime errors, and fix the errors in the course report's Java.
  • Compare the two languages on typing, syntax, compilation, speed and uses, and choose what to learn next.
  • بچووکی Java بخوێنیتەوە: ، main، ناساندنەکان، کەوانە و .
  • ڕوونی بکەیتەوە javac و JVM چۆن Java جێبەجێ دەکەن و چۆن جێبەجێ دەکات، بە شێوازی ئەمڕۆی .
  • ، بڕیاردان، ، و لە نێوان و Javaـدا وەربگێڕیت.
  • لە جیا بکەیتەوە و هەڵەکانی Javaـی ڕاپۆرتی کۆرسەکە چاک بکەیتەوە.
  • دوو زمانەکە لە جۆرداری، ، کۆمپایلکردن، خێرایی و بەکارهێناندا بەراورد بکەیت و هەڵبژێریت دواتر فێری چی ببیت.

Why look at Java?بۆچی سەیری Java بکەین؟

You have finished the Python track. Before you go on, it helps to see how the same ideas look in another language. Java is a good partner: it is one of the most used languages for servers, banks and big companies, and it makes different choices from Python.

ڕێڕەوی Pythonـت تەواو کرد. پێش ئەوەی بڕۆیتە پێشەوە، بەسوودە ببینیت هەمان بیرۆکەکان لە زمانێکی تردا چۆن دەردەکەون. هاوەڵێکی باشە: یەکێکە لە بەکارهاتووترین زمانەکان بۆ ، بانک و کۆمپانیا گەورەکان و هەڵبژاردنی جیاواز لە دەکات.

This lesson takes the examples of the course report “Python and Java” — variables, printing, comments, decisions, loops, functions, lists and arrays — and puts the Python code and the Java code side by side. Every Java example was corrected, compiled and run.

ئەم وانەیە نموونەکانی ڕاپۆرتی کۆرسەکە «⁦Python and Java⁩» وەردەگرێت — ، چاپکردن، ، بڕیاردان، ، ، و — و کۆدی و کۆدی لە تەنیشت یەکەوە دادەنێت. هەموو نموونەیەکی ڕاست کرایەوە، کۆمپایل کرا و جێبەجێ کرا.

Quick checkپشکنینی خێراWhat is the goal of this lesson?ئامانجی ئەم وانەیە چییە؟

فێربوونی بنەماکانی پرۆگرامسازی بە زمانی جاڤا (١) | Learn the Fundamentals of Programming in Java (1)Birtech Academy - ئەکادیمیایی بیرتێک · Kurdish (Sorani)کوردی (سۆرانی) · 3.5K viewsبینین · 176 likesلایک · Partبەشی 10:15–12:33 (ofلە 12:34)

In Kurdish: what Java is — its start in 1995, its owner Oracle, that it is object-oriented, and the kinds of apps people build with it.

بە کوردی: چییە: لە ساڵی ⁦1995⁩ دەستی پێکرد، خاوەنەکەی Oracleـە، و چ جۆرە پێی دروست دەکرێت.

Kurdish (Sorani). Watch 10:15-12:33: the Java slide — made in 1995 by James Gosling's team, now owned by Oracle, object-oriented, and used for desktop, web, mobile and business apps and games. The earlier part is a general introduction to programming that students of this lesson already know.

ڤیدیۆیەکی کوردی (سۆرانی)، لە ⁦10:15⁩ تا ⁦12:33⁩ سەیر بکە: : لە ساڵی ⁦1995⁩ تیمەکەی ⁦James Gosling⁩ دروستیان کرد، ئێستا هی Oracleـە، و بۆ ، ، مۆبایل و بازرگانی، هەروەها بەکاردێت. بەشی پێشووتر ناساندنێکی گشتییە بۆ کە قوتابیانی ئەم وانەیە پێشتر دەیزانن.

Hello World in both languages⁦Hello World⁩ لە هەردوو زماندا

The smallest program shows the biggest difference. In Python one line is a complete program. In Java every program lives inside a class, and running starts in a special method called main.

بچووکترین گەورەترین جیاوازی پیشان دەدات. لە Pythonـدا یەک دێڕ تەواوە. لە Javaـدا هەموو لە ناو دا دەژی و جێبەجێکردن لە تایبەتدا بە ناوی main دەست پێ دەکات.

Top: the Python program print("Hello World") in hello.py — the whole program is one line. Bottom: the Java program in Hello.java with four numbered parts: 1, public class Hello: every Java program lives in a class, and a public class goes in a file with its name; 2, the main method, where Java starts running; 3, System.out.println("Hello World"); prints one line and the semicolon ends the statement; 4, the closing braces: each { has a matching } and the braces mark the blocks.سەرەوە: بەرنامەی Python print("Hello World") لە hello.py — هەموو بەرنامەکە یەک دێڕە. خوارەوە: بەرنامەی Java لە Hello.java بە چوار بەشی ژمارەدار: 1، public class Hello: هەموو بەرنامەیەکی Java لە ناو کلاسێکدایە و کلاسێکی public دەچێتە فایلێکی هاوناوی خۆی؛ 2، میتۆدی main کە Java لێیەوە دەست بە جێبەجێکردن دەکات؛ 3، System.out.println("Hello World"); دێڕێک چاپ دەکات و خاڵبۆر ڕستەکە تەواو دەکات؛ 4، کەوانە داخەرەکان: هەر کەوانەیەکی کراوە کەوانەیەکی داخراوی هاوتای هەیە و کەوانەکان بلۆکەکانی کۆد دیاری دەکەن.
The parts of a Java programبەشەکانی CêIT
hello.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
print("Hello World")
Hello.javaJAVAType in a terminalلە تێرمیناڵدا بینووسە
public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 1

public class Hello — the class name must match the file name Hello.java.

public class Hello — ناوی دەبێت وەک ناوی Hello.java بێت.

Lineدێڕی 2

public static void main(String[] args) — the fixed first line of every program's start. void: it returns nothing; String[] args: words typed after the program name.

public static void main(String[] args) — دێڕی جێگیری دەستپێکی هەموو . void: هیچ ناگەڕێنێتەوە؛ String[] args: ئەو وشانەی دوای ناوی دەنووسرێن.

Lineدێڕی 3

System.out.println = “print line”: it prints the text and then a new line, like Python's print(). The ; ends the statement.

System.out.println = «⁦print line⁩»: دەقەکە چاپ دەکات و پاشان دێڕێکی نوێ، وەک print()ـی . ; تەواو دەکات.

Quick checkپشکنینی خێراWhich line prints Hello World in Java?کام دێڕ لە Javaـدا Hello World چاپ دەکات؟

Java in 100 SecondsFireship · Englishئینگلیزی · 1.7M viewsبینین · 85K likesلایک

What Java is: code compiled to bytecode that the JVM runs, a class with a main method, then compiling with javac and running with java.

چییە: کۆد بۆ کۆمپایل دەکرێت و JVM جێبەجێی دەکات، بە main، پاشان کۆمپایلکردن بە javac و جێبەجێکردن بە java.

A fast 2:25 overview: how Java works (0:28), the class and its main method (1:11) and compile and run (2:00).

پێداچوونەوەیەکی خێرای ⁦2:25⁩: چۆن کار دەکات ⁦(0:28)⁩، و mainـەکەی ⁦(1:11)⁩ و کۆمپایلکردن و جێبەجێکردن ⁦(2:00)⁩.

Hello World in both languages⁦Hello World⁩ لە هەردوو زماندا

Compiling and runningکۆمپایلکردن و جێبەجێکردن

Java has two commands. javac (the Java compiler) checks the whole file and translates it into bytecode in a .class file. java starts the Java virtual machine (JVM), which runs that bytecode. Python does both steps with one command.

دوو هەیە. javac ( ) هەموو دەپشکنێت و دەیکات بە لە .classـدا. java ⁦(JVM)⁩ دەست پێ دەکات کە ئەو جێبەجێ دەکات. هەردوو هەنگاو بە یەک دەکات.

Java: compile, then run (real terminal run)Java: کۆمپایل، پاشان جێبەجێکردن (جێبەجێکردنی ڕاستەقینە لە تێرمیناڵدا)
$ javac Hello.java
$ ls
Hello.class
Hello.java
$ java Hello
Hello World
Python: one commandPython: یەک فەرمان
$ python3 hello.py
Hello World

Since Java 11 you can also type java Hello.java: the launcher compiles the file in memory and runs it at once. That is handy for small programs; bigger programs are still compiled with javac (or a build tool).

لە ⁦Java 11⁩ـەوە دەتوانیت java Hello.javaـیش بنووسیت: لە کۆمپایل دەکات و یەکسەر جێبەجێی دەکات. ئەمە بۆ بچووک بەسوودە؛ گەورەتر هێشتا بە javac (یان ئامرازێکی دروستکردن) کۆمپایل دەکرێن.

Quick checkپشکنینی خێراWhat does javac Hello.java produce?javac Hello.java چی دروست دەکات؟

Hello World in both languages⁦Hello World⁩ لە هەردوو زماندا

How the two languages run todayدوو زمانەکە ئەمڕۆ چۆن کار دەکەن

Both languages translate your code before it runs; they differ in when they do it and what they check first.

هەردوو زمان پێش جێبەجێکردن کۆدەکەت وەردەگێڕن؛ جیاوازییەکەیان لەوەدایە کەی ئەمە دەکەن و سەرەتا چی دەپشکنن.

TopicبابەتPython (CPython)Java
You typeدەنووسیتpython3 hello.pyjavac Hello.java then java Hello
TranslationوەرگێڕانPython compiles the file to bytecode by itself, every run (cached in .pyc files for imported modules) خۆی لە هەموو جێبەجێکردنێکدا دەکات بە (بۆ کە import دەکرێن لە ⁦.pyc⁩ـدا هەڵدەگیرێت)You compile first with javac; the .class files keep the bytecodeسەرەتا خۆت بە javac کۆمپایل دەکەیت؛ ⁦.class⁩ هەڵدەگرن
Who runs the bytecodeکێ جێبەجێ دەکاتThe Python virtual machine, instruction by instruction (an experimental JIT exists since Python 3.13; it is still switched off by default) ، ڕێنمایی بە ڕێنمایی ( JITـی تاقیکاری لە ⁦Python 3.13⁩ـەوە هەیە، بەڵام هێشتا بە شێوەی بنەڕەت کوژاوەیە)The JVM: it interprets, then compiles busy (“hot”) methods to machine code with its JIT compilerJVM: سەرەتا ئینتەرپرێت دەکات، پاشان («گەرم») بە دەکات بە
Grammar and type mistakesهەڵەی و جۆرGrammar: before the file runs. Types and unknown names: only when that line runs: پێش جێبەجێبوونی . جۆر و ناوی نەناسراو: تەنها کاتێک ئەو دێڕە جێبەجێ دەبێتAll of them before anything runs (compile-time errors)هەموویان پێش ئەوەی هیچ جێبەجێ بێت ()
Quick checkپشکنینی خێراIn today's model, what do CPython and the JVM both run?لە شێوازی ئەمڕۆدا، CPython و JVM هەردووکیان چی جێبەجێ دەکەن؟

Same program, two languagesهەمان بەرنامە، دوو زمان

Here is a slightly bigger job: add the numbers 1 to 5. Watch how each Python line has a partner line in Java, and what Java adds around them.

ئەمە کارێکی کەمێک گەورەترە: ژمارەکانی 1 تا 5 کۆ بکەرەوە. سەیر بکە چۆن هەر دێڕێکی دێڕێکی هاوتای لە Javaـدا هەیە و چی بە دەوریاندا زیاد دەکات.

Animation. Left: the 4-line Python program total = 0, for i in range(1, 6), total += i, print. Right: the Java version appears step by step. First the class and main lines around the code; then int total = 0; next to total = 0; then the for line with start, condition and step; then total += i; and its closing brace next to the indented Python body; then System.out.println next to print. Last frame: both print Total: 15 — 4 lines against 9.
Animation. Left: the 4-line Python program total = 0, for i in range(1, 6), total += i, print. Right: the Java version appears step by step. First the class and main lines around the code; then int total = 0; next to total = 0; then the for line with start, condition and step; then total += i; and its closing brace next to the indented Python body; then System.out.println next to print. Last frame: both print Total: 15 — 4 lines against 9.
Each Python line and its Java partnerهەر دێڕێکی و هاوتاکەی لە JavaـداCêIT
total.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
total = 0
for i in range(1, 6):
    total += i
print("Total:", total)
Total.javaJAVAType in a terminalلە تێرمیناڵدا بینووسە
public class Total {
    public static void main(String[] args) {
        int total = 0;
        for (int i = 1; i <= 5; i++) {
            total += i;
        }
        System.out.println("Total: " + total);
    }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 3

A variable needs its type: int = whole number.

جۆرەکەی پێویستە: int = .

Lineدێڕی 4

Start int i = 1; condition i <= 5; step i++ (add 1). Python's range(1, 6) says the same.

دەستپێک int i = 1؛ i <= 5؛ هەنگاو i++ (⁦1⁩ زیاد بکە). range(1, 6)ـی هەمان شت دەڵێت.

Lineدێڕی 5-6

The body is between { and }; the indentation is only for people.

جەستە لە نێوان { و }ـدایە؛ تەنها بۆ خەڵکە.

Lineدێڕی 7

+ joins text and a number into one string.

+ دەق و ژمارەیەک دەکات بە یەک .

Quick checkپشکنینی خێراIn Java, what marks the body of the for loop?لە Javaـدا چی جەستەی دیاری دەکات؟

Variables and typesگۆڕاوەکان و جۆرەکان

In Python you create a variable by giving it a value. In Java you first declare it: you write its type, its name, and usually a first value, and end with ;.

لە Pythonـدا بە پێدانی دروست دەکەیت. لە Javaـدا سەرەتا دەیناسێنیت: جۆرەکەی، ناوەکەی و زۆرجار یەکەم دەنووسیت و بە ; کۆتایی پێ دەهێنیت.

TopicبابەتPythonJava
Syntaxvar_name = valuedatatype var_name = value;
Exampleنموونەage = 21int age = 21;
vars.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
age = 21
price = 2.5
is_raining = True
grade = "A"
name = "Shilan"
print(name, "is", age)
print(price, is_raining, grade)

age = 22
total = float(age)    # Python converts only when you ask
print(total)
age = "twenty-two"    # allowed: the name now points to a string
print(type(age))
Variables.javaJAVAType in a terminalلە تێرمیناڵدا بینووسە
public class Variables {
    public static void main(String[] args) {
        int age = 21;               // whole number
        double price = 2.5;         // decimal number
        boolean isRaining = true;   // true or false
        char grade = 'A';           // one character, single quotes
        String name = "Shilan";     // text: a class, capital S

        System.out.println(name + " is " + age);
        System.out.println(price + " " + isRaining + " " + grade);

        age = 22;                   // a new value of the same type is fine
        double total = age;         // an int widens to a double by itself
        System.out.println(total);
    }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 3-7

Each declaration names a type. char uses single quotes; String uses double quotes and starts with a capital S.

هەر ناساندنێک ناوی جۆرێک دەهێنێت. char کۆتەیشنی تاک بەکار دەهێنێت؛ String کۆتەیشنی جووت بەکار دەهێنێت و بە Sـی گەورە دەست پێ دەکات.

Lineدێڕی 9

In Java, + turns the number into text when one side is a String.

لە Javaـدا، کاتێک لایەکی String بێت، + ژمارەکە دەکات بە دەق.

Lineدێڕی 12

A new value of the same type is fine. age = "twenty-two"; would not compile.

نوێ لە هەمان جۆر کێشە نییە. age = "twenty-two"; کۆمپایل نابێت.

Lineدێڕی 13-14

An int fits into a double by itself (widening): 22 becomes 22.0.

int خۆی دەچێتە ناو double (فراوانکردن): ⁦22⁩ دەبێت بە ⁦22.0⁩.

Quick checkپشکنینی خێراWhich Java declaration is correct?کام ناساندنی دروستە؟

Variables and typesگۆڕاوەکان و جۆرەکان

Java's eight primitive typesهەشت جۆرە سەرەتاییەکانی Java

Java has eight primitive types for simple values. Their names are written in small letters. Everything else — text, arrays, lists, your own classes — is an object; that is why String starts with a capital letter. Java is case-sensitive, so string is not the same name as String.

لە Javaـدا هەشت هەیە بۆ . ناوەکانیان بە پیتی بچووک دەنووسرێن. هەموو شتێکی تر — دەق، ، ، خۆت — ؛ بۆیە String بە پیتی گەورە دەست پێ دەکات. ، بۆیە string هەمان ناوی String نییە.

The eight primitive types (Java Language Specification, §4.2)هەشت (⁦Java Language Specification⁩، §⁦4.2⁩)
Java primitive type لە JavaـداHoldsهەڵدەگرێتNearest Python typeنزیکترین جۆری Python
bytewhole number, 8 bits (−128-128 to 127)، 8 بیت (−128-128 تا ⁦127⁩)int
shortwhole number, 16 bits، ⁦16⁩ بیتint
intwhole number, 32 bits — the usual choice، ⁦32⁩ بیت — هەڵبژاردنی ئاساییint
longwhole number, 64 bits، ⁦64⁩ بیتint
floatdecimal number, 32 bits، ⁦32⁩ بیتfloat
doubledecimal number, 64 bits — the usual choice، ⁦64⁩ بیت — هەڵبژاردنی ئاساییfloat
charone character, in single quotes: 'A'یەک ، لە ناو کۆتەیشنی تاکدا: 'A'a string of length 1 بە درێژیی 1
booleantrue or false (small letters)true یان false (پیتی بچووک)bool: True / Falsebool: True / False
Quick checkپشکنینی خێراWhich of these is not one of Java's primitive types?کامیان یەکێک لە Java نییە؟

Variables and typesگۆڕاوەکان و جۆرەکان

Type mistakes: before or during the run?هەڵەی جۆر: پێش جێبەجێکردن یان لە کاتیدا؟

Because Java knows every variable's type, javac finds type mistakes before the program runs: a compile-time error. The course report itself had one — it declared a temperature as boolean:

لەبەر ئەوەی جۆری هەموو دەزانێت، javac هەڵەی جۆر پێش جێبەجێبوونی دەدۆزێتەوە: . ڕاپۆرتی کۆرسەکە خۆی یەکێکی تێدا بوو — پلەی گەرمی بە boolean ناساندبوو:

javac: boolean temp = 30;javac بۆ ⁦boolean temp = 30;⁩
Main.java:4: error: incompatible types: int cannot be converted to boolean
        boolean temp = 30;
                       ^
1 error

boolean holds only true or false; a temperature is a whole number, so the fix is int temp = 30;. The same check stops text in a number variable:

boolean تەنها true یان false هەڵدەگرێت؛ پلەی گەرمی ، بۆیە چارەسەرەکە int temp = 30;ـە. هەمان پشکنین ڕێگە لە دەق دەگرێت لە ژمارەدا:

javac: int age = "twenty";javac بۆ ⁦int age = "twenty";⁩
Main.java:3: error: incompatible types: String cannot be converted to int
        int age = "twenty";
                  ^
1 error

Python checks types while the program runs. The mistake below is found only when line 2 is reached. Notice also that Python's + does not turn numbers into text; use str(age) or an f-string.

جۆرەکان لە کاتی جێبەجێبوونی دەپشکنێت. هەڵەی خوارەوە تەنها کاتێک دەدۆزرێتەوە کە دەگاتە دێڕی 2. هەروەها تێبینی بکە کە +ـی ژمارە ناکات بە دەق؛ str(age) یان بەکار بهێنە.

concat.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
age = 21
print("Age: " + age)
Definitionپێناسە

An that the finds while it translates the , before the program runs: a missing ;, a misspelt name or a wrong type such as int age = "twenty";. Nothing runs until it is fixed. Compare .

کە لە کاتی وەرگێڕانی دەیدۆزێتەوە، پێش ئەوەی کار بکات: ;ـێکی ونبوو، ناوێکی هەڵە نووسراو یان جۆرێکی هەڵە وەک int age = "twenty";. تا چاک نەکرێت هیچ جێبەجێ نابێت. بەراوردی بکە لەگەڵ .

Quick checkپشکنینی خێراWhen does Java report int age = "twenty";? کەی int age = "twenty"; ڕاپۆرت دەکات؟

Printing and commentsچاپکردن و لێدوانەکان

Printing and comments side by sideچاپکردن و لە تەنیشت یەکەوە
TopicبابەتPythonJava
Print, then a new lineچاپکردن، پاشان دێڕی نوێprint("Hi")System.out.println("Hi");
Print, stay on the lineچاپکردن، مانەوە لە هەمان دێڕprint("Hi", end="")System.out.print("Hi");
Text and a numberدەق و ژمارەprint("Age:", age)System.out.println("Age: " + age);
One-line comment یەک دێڕی# comment// comment
Comment over several lines بە چەند دێڕ# on every line# لەسەر هەموو دێڕێک/* comment */
Documentation"""docstring""" as the first line of a function"""docstring""" وەک یەکەم دێڕی /** javadoc comment */
Greeter.javaJAVAType in a terminalلە تێرمیناڵدا بینووسە
/**
 * Prints greetings. The javadoc tool turns this
 * documentation comment into a web page.
 */
public class Greeter {
    public static void main(String[] args) {
        // This is a one-line comment
        /*
        A multiline
        comment
        */
        System.out.println("Hello World");   // a comment can follow code
    }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 1-4

A documentation comment starts with /**. The javadoc tool reads these comments and builds web pages that describe the classes and methods.

بە /** دەست پێ دەکات. ئامرازی javadoc ئەم دەخوێنێتەوە و پەڕەی وێب دروست دەکات کە و وەسف دەکەن.

Lineدێڕی 7

// hides the rest of the line from the compiler.

// باقیی دێڕەکە لە دەشارێتەوە.

Lineدێڕی 8-11

/* ... */ can cover several lines.

/* ... */ دەتوانێت چەند دێڕێک بگرێتەوە.

Lineدێڕی 12

A comment can also follow code on the same line.

دەتوانێت دوای کۆد لە هەمان دێڕدا بێت.

Quick checkپشکنینی خێراWhich Java comment can the javadoc tool turn into documentation pages?کام ئامرازی javadoc دەتوانێت بیکات بە پەڕەی ؟

Decisions: if, else if, elseبڕیاردان: if، ⁦else if⁩، else

The idea is the same in both languages; only the spelling changes. Python writes elif, Java writes else if. Java needs parentheses around every condition and braces around every block. Python needs neither, only the colon and the indentation.

بیرۆکەکە لە هەردوو زماندا وەک یەکە؛ تەنها نووسینەکە دەگۆڕێت. elif دەنووسێت، else if. کەوانەی بچووکی بە دەوری هەموو و کەوانەی گەورەی بە دەوری هەموو پێویستە. هیچیانی پێویست نییە، تەنها دوو خاڵ و .

From here on, the short Java examples show only the lines that go inside main. To run one, put it inside the class and the main method of Hello World.

لێرەوە بە دواوە، نموونە کورتەکانی Java تەنها ئەو دێڕانە پیشان دەدەن کە دەچنە ناو main. بۆ جێبەجێکردنی یەکێکیان، بیخەرە ناو و mainـی ⁦Hello World⁩.

grade.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
num = 80
if num >= 80:
    print("Excellent!")
elif num >= 50:
    print("Good.")
else:
    print("Failed!")
Main.java (inside main)JAVAType in a terminalلە تێرمیناڵدا بینووسە
int num = 80;
if (num >= 80) {
    System.out.println("Excellent!");
} else if (num >= 50) {
    System.out.println("Good.");
} else {
    System.out.println("Failed!");
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 2

The condition in parentheses, the block in braces.

لە ناو کەوانەی بچووکدا، لە ناو کەوانەی گەورەدا.

Lineدێڕی 4

} else if (...) { is Java's elif.

} else if (...) { هاوتای elifـی Javaـیە.

Logical words and symbolsوشە و لۆجیکی
TopicبابەتPythonJava
and / or / notو / یان / ناa and b, a or b, not aa && b, a || b, !a
True / Falseڕاست / هەڵەTrue, Falsetrue, false
Equal / not equal (numbers)یەکسان / نایەکسان (ژمارە)==, !===, !=
Quick checkپشکنینی خێراHow do you write Python's elif num >= 50: in Java?چۆن elif num >= 50:ـی لە Javaـدا دەنووسیت؟

Decisions: if, else if, elseبڕیاردان: if، ⁦else if⁩، else

A nested if: what to wearڕستەی ifـی ناوەکی: چی لەبەر بکەین

The report's second example chooses advice by the weather. Its messages are in Kurdish written with Latin letters:

نموونەی دووەمی ڕاپۆرتەکە بەپێی کەش و هەوا ئامۆژگاری هەڵدەبژێرێت. پەیامەکانی بە کوردیی نووسراو بە پیتی لاتینین:

Message in the codeپەیام لە کۆدەکەداMeaningواتاWhenکەی
Ştêkî tenîk leber bike.Wear something light.شتێکی تەنک لەبەر بکە.raining, above 20°باران، سەرووی ⁦20°⁩
Cilêkî estûr leber bike.Wear thick clothes.جلێکی ئەستوور لەبەر بکە.raining, 20° or lessباران، ⁦20°⁩ یان کەمتر
Keşekey xirap nîye.The weather is not bad.کەشەکە خراپ نییە.snowing, above 10°بەفر، سەرووی ⁦10°⁩
Agadarî tendrûstît be.Look after your health.ئاگاداری تەندروستیت بە.snowing, 10° or lessبەفر، ⁦10°⁩ یان کەمتر
Rojêkî xweşe!It's a nice day!ڕۆژێکی خۆشە!no rain, no snowنە باران، نە بەفر
weather.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
is_raining = True
is_snowing = False
temp = 30
if is_raining:
    if temp > 20:
        print("Ştêkî tenîk leber bike.")
    else:
        print("Cilêkî estûr leber bike.")
elif is_snowing:
    if temp > 10:
        print("Keşekey xirap nîye.")
    else:
        print("Agadarî tendrûstît be.")
else:
    print("Rojêkî xweşe!")
Main.java (inside main)JAVAType in a terminalلە تێرمیناڵدا بینووسە
boolean isRaining = true;
boolean isSnowing = false;
int temp = 30;
if (isRaining) {
    if (temp > 20) {
        System.out.println("Ştêkî tenîk leber bike.");
    } else {
        System.out.println("Cilêkî estûr leber bike.");
    }
} else if (isSnowing) {
    if (temp > 10) {
        System.out.println("Keşekey xirap nîye.");
    } else {
        System.out.println("Agadarî tendrûstît be.");
    }
} else {
    System.out.println("Rojêkî xweşe!");
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 1-3

Corrected declarations: isSnowing is now declared, and temp is an int.

ناساندنە ڕاستکراوەکان: isSnowing ئێستا ناسێنراوە و temp intـە.

Lineدێڕی 4-9

An if inside an if: each inner block has its own braces.

ifـێک لە ناو ifـێکدا: هەر بلۆکێکی ناوەوە کەوانەی خۆی هەیە.

The report never declared isSnowing in either language. The two languages react very differently. Java refuses to compile the file at all:

ڕاپۆرتەکە لە هیچ کام لە دوو زمانەکەدا isSnowingـی نەناساندبوو. دوو زمانەکە زۆر بە جیاوازی کاردانەوەیان هەیە. بە هیچ شێوەیەک کۆمپایل ناکات:

javac: isSnowing is not declaredjavac بۆ isSnowing نەناسێنراوە
Main.java:7: error: cannot find symbol
        } else if (isSnowing) {
                   ^
  symbol:   variable isSnowing
  location: class Main
1 error

Python runs happily while it is raining, because the elif line is never reached. Only on a dry day does it crash:

تا باران ببارێت بە ئاسایی کار دەکات، چونکە هەرگیز ناگاتە دێڕی elif. تەنها لە ڕۆژێکی وشکدا دەوەستێت:

weather.py (the report's version, isRaining = False)PYTHONType in a terminalلە تێرمیناڵدا بینووسە
isRaining = False
temp = 30
if (isRaining):
  if (temp > 20):
        print("Ştêkî tenîk leber bike.")
  else:
        print("Cilêkî estûr leber bike.")
elif (isSnowing):
  if (temp > 10):
        print("Keşekey xirap nîye.")
  else:
        print("Agadarî tendrûstît be.")
else:
  print("Rojêkî xweşe!")
Quick checkپشکنینی خێراWith isRaining = True, the report's Python program prints its message without an error. Why?بە isRaining = True، Pythonـی ڕاپۆرتەکە پەیامەکەی بەبێ چاپ دەکات. بۆچی؟

Loops: while and forخولەکان: while و for

A while loop looks almost the same in both languages. Java adds parentheses, braces and ;, and it has the short form i++ for “add 1 to i”; Python writes i += 1.

لە هەردوو زماندا نزیکەی وەک یەکە. Java کەوانەی بچووک، کەوانەی گەورە و ; زیاد دەکات و شێوە کورتەکەی i++ـی هەیە بۆ «1 بخەرە سەر i»؛ i += 1 دەنووسێت.

count.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
i = 1
while i <= 10:
    print(i)
    i += 1
Main.java (inside main)JAVAType in a terminalلە تێرمیناڵدا بینووسە
int i = 1;
while (i <= 10) {
    System.out.println(i);
    i++;            // the same as i = i + 1;
}

The counting for loop is where the languages differ most. Java's classic for has three parts in its header, separated by ;: start (int i = 1), condition (i <= 10) and step (i++). Python's for walks through a sequence, and range(1, 11) makes the numbers 1 to 10.

بۆ ژماردن ئەو شوێنەیە کە زمانەکان زۆرترین جیاوازییان هەیە. لە Javaـدا کلاسیک سێ بەشی لە سەرەکەیدا هەیە کە بە ; جیا دەکرێنەوە: دەستپێک (int i = 1)، (i <= 10) و هەنگاو (i++). لە Pythonـدا بە ناو دەڕوات و range(1, 11) ژمارەکانی 1 تا ⁦10⁩ دروست دەکات.

examples.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
for i in range(1, 11):
    print("Example", i)
Main.java (inside main)JAVAType in a terminalلە تێرمیناڵدا بینووسە
for (int i = 1; i <= 10; i++) {
    System.out.println("Example " + i);
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 1

start; condition; step

دەستپێک؛ ؛ هەنگاو

Lineدێڕی 2

The report forgot this ;. "Example " + i needs the space inside the quotes, because Java's + adds none.

ڕاپۆرتەکە ئەم ;ـەی لەبیر کردبوو. "Example " + i پێویستی بە لە ناو کۆتەیشنەکاندا هەیە، چونکە +ـی Java هیچ زیاد ناکات.

Java's loops and their Python partners Java و هاوتاکانیان لە Pythonـدا
Java loop JavaWhen to use itکەی بەکاری دەهێنیتPython wayڕێگای Python
for (int i = 1; i <= 10; i++) { … }You know how many timesدەزانیت چەند جارfor i in range(1, 11):
while (condition) { … }You do not know how many times; test firstنازانیت چەند جار؛ سەرەتا پشکنینwhile condition:
do { … } while (condition);The body must run at least once; test lastجەستە دەبێت لانیکەم یەک جار جێبەجێ بێت؛ پشکنین لە کۆتاییداwhile True: … if not condition: breakwhile True: … if not condition: break
for (String w : words) { … }Visit every item of an array or listسەردانی هەموو یان for w in words:
for (;;) / while (true) / do { … } while (true);A loop that runs until break کە تا break کار دەکاتwhile True:
Quick checkپشکنینی خێراWhich Java header counts 1, 2, 3, 4, 5?کام سەرەی ⁦Java 1⁩، 2، 3، 4، 5 دەژمێرێت؟

Loops: while and forخولەکان: while و for

do … while: Java onlydo … while: تەنها لە Javaـدا

Java has a third loop that Python does not have: do … while. It runs the body first and tests the condition afterwards, so the body always runs at least once — useful for menus (“show the menu, then ask whether to show it again”).

Java سێیەمی هەیە کە نییەتی: do … while. سەرەتا جەستەکە جێبەجێ دەکات و دواتر دەپشکنێت، بۆیە جەستەکە هەمیشە لانیکەم یەک جار جێبەجێ دەبێت — بۆ بەسوودە (« پیشان بدە، پاشان بپرسە دووبارە پیشانی بدەیتەوە یان نا»).

Main.java (inside main)JAVAType in a terminalلە تێرمیناڵدا بینووسە
int n = 10;
do {
    System.out.println("n is " + n);
    n++;
} while (n < 5);
System.out.println("Finished with n = " + n);
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 2-5

The body runs once with n = 10. Only then is n < 5 tested: false, so the loop ends.

جەستەکە یەک جار بە n = 10 جێبەجێ دەبێت. تەنها پاشان n < 5 دەپشکنرێت: هەڵەیە، بۆیە کۆتایی دێت.

Lineدێڕی 5

A do … while ends with ; after the condition.

do … while دوای بە ; کۆتایی دێت.

dowhile.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
n = 10
while True:
    print("n is", n)
    n += 1
    if not n < 5:       # the do-while test, at the bottom
        break
print("Finished with n =", n)
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 2

Python: start an endless loop …

: بێکۆتا دەست پێ بکە …

Lineدێڕی 5-6

… and test at the bottom, with break.

… و لە خوارەوە بە break بپشکنە.

Quick checkپشکنینی خێراint n = 3; do { n++; } while (n < 5); — what is n at the end?int n = 3; do { n++; } while (n < 5); — n لە کۆتاییدا چەندە؟

Loops: while and forخولەکان: while و for

Where a variable livesگۆڕاوێک لە کوێ دەژی

In Java a variable declared inside a block { … } — or in a for header — exists only inside that block (block scope). Using it after the block is a compile-time error, and you cannot declare the same name twice in one method:

لە Javaـدا کە لە ناو بلۆکێکی { … } — یان لە سەرەی forـدا — ناسێنرابێت تەنها لە ناو ئەو بلۆکەدا بوونی هەیە (). بەکارهێنانی دوای بلۆکەکە و ناتوانیت هەمان ناو دوو جار لە یەک بناسێنیت:

Main.javaJAVAType in a terminalلە تێرمیناڵدا بینووسە
public class Main {
    public static void main(String[] args) {
        for (int k = 1; k <= 3; k++) {
            int square = k * k;
        }
        System.out.println(k);
    }
}
Main.javaJAVAType in a terminalلە تێرمیناڵدا بینووسە
public class Main {
    public static void main(String[] args) {
        int i = 1;
        while (i <= 3) {
            i++;
        }
        for (int i = 1; i <= 3; i++) {
            System.out.println(i);
        }
    }
}

Python has no block scope: a loop or an if does not make a new scope, so the loop variable is still there after the loop (see Variable scope).

نییە: یان if نوێ دروست ناکات، بۆیە دوای هەر دەمێنێتەوە (بڕوانە مەودا).

scope.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
for k in range(1, 4):
    square = k * k
print(k, square)      # both names still exist after the loop
Quick checkپشکنینی خێراA Java for (int k = 1; k <= 3; k++) { … } has finished. Can the next line print k?لە Javaـدا وەک for (int k = 1; k <= 3; k++) { … } تەواو بووە. ئایا دێڕی دواتر دەتوانێت k چاپ بکات؟

Functions and methodsکردارەکان و میتۆدەکان

Python lets you write a function anywhere in a file. In Java every function lives inside a class and is called a method. For now you write static before it, which means “it belongs to the class; no object is needed”. Java also writes the return type: void for nothing, int for a whole number, and so on.

ڕێگەت پێ دەدات لە هەر شوێنێکی بنووسیت. لە Javaـدا هەموو لە ناو دەژی و پێی دەوترێت . بۆ ئێستا static لە پێشیەوە دەنووسیت، واتە «سەر بە ؛ هیچ پێویست نییە». Java هەروەها جۆری دەنووسێت: void بۆ هیچ، int بۆ و هتد.

methods.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
def say_hello():
    print("Hello World!")


def square(n):
    return n * n


say_hello()
print(square(7))
Main.javaJAVAType in a terminalلە تێرمیناڵدا بینووسە
public class Main {
    public static void main(String[] args) {
        sayHello();
        System.out.println(square(7));
    }

    static void sayHello() {
        System.out.println("Hello World!");
    }

    static int square(int n) {
        return n * n;
    }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 3-4

main calls the two methods, like the last lines of the Python file.

main بانگی دوو دەکات، وەک دوا دێڕەکانی Python.

Lineدێڕی 7

void: returns nothing. Method names use camelCase in Java: sayHello, not say_hello.

void: هیچ ناگەڕێنێتەوە. ناوی لە Javaـدا camelCaseـن: sayHello، نەک say_hello.

Lineدێڕی 11-12

int square(int n): the parameter has a type, and so does the result.

int square(int n): جۆری هەیە، هەروەها.

Quick checkپشکنینی خێراWhat does void mean in static void sayHello()?void لە static void sayHello()ـدا چی دەگەیەنێت؟

Python lists and Java arraysلیستەکانی Python و ڕیزەکەکانی Java

A Python list grows as you append(). A Java array is created with a fixed length: new String[2] makes exactly two boxes, numbered 0 and 1. Every element must have the array's type. The boxes sit next to each other in memory, so Java finds any box from its index at once.

بە append() گەورە دەبێت. Java بە درێژییەکی جێگیر دروست دەکرێت: new String[2] ڕێک دوو خانە دروست دەکات بە ژمارەکانی 0 و 1. هەموو دەبێت جۆری هەبێت. خانەکان لە لە تەنیشت یەکەوەن، بۆیە Java هەر خانەیەک لە ڕێگەی یەکسەر دەدۆزێتەوە.

countries.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
country = []
country.append("Kurdistan")
country.append("Egypt")
for j in country:
    print(j)
Main.java (inside main)JAVAType in a terminalلە تێرمیناڵدا بینووسە
String[] country = new String[2];
country[0] = "Kurdistan";
country[1] = "Egypt";
for (String j : country) {
    System.out.println(j);
}
System.out.println("Length: " + country.length);
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 1

String[] = “array of Strings”; new String[2] reserves 2 boxes. The report wrote new string[2].

String[] = « String»؛ new String[2] دوو خانە دیاری دەکات. ڕاپۆرتەکە new string[2]ـی نووسیبوو.

Lineدێڕی 4

The enhanced for: “for each String j in country”.

forـی پەرەپێدراو: «بۆ هەر ⁦String j⁩ لە country».

Lineدێڕی 7

.length gives the fixed size.

.length قەبارە جێگیرەکە دەدات.

Top, Java: int[] marks = {90, 75, 60, 88, 95}; five boxes in a row with the elements 90, 75, 60, 88, 95 above the indexes 0 to 4. The box at index 3 (88) is marked marks[3]. A bracket says marks.length is 5 and can never change. A crossed-out dashed box marks[5] says there is no box 5: an error. Bottom, Python: marks = [90, 75, 60, 88, 95] and marks.append(70); the same five boxes plus a sixth box 70 at index 5: append adds a box, a list grows; Java's ArrayList can grow too.سەرەوە، Java: int[] marks = {90, 75, 60, 88, 95}؛ پێنج خانە لە ڕیزێکدا بە دانەکان 90، 75، 60، 88، 95 لە سەرووی ئیندێکسەکان 0 تا 4. خانەی ئیندێکسی 3 (88) بە marks[3] دیاری کراوە. کەوانەیەک دەڵێت درێژیی ڕیزەکەکە 5ـە و هەرگیز ناگۆڕێت. خانەیەکی پچڕپچڕی خەتلێدراو marks[5] دەڵێت خانەی 5 نییە: هەڵە. خوارەوە، Python: marks = [90, 75, 60, 88, 95] و marks.append(70)؛ هەمان پێنج خانە لەگەڵ خانەی شەشەم 70 لە ئیندێکسی 5: append خانەیەک زیاد دەکات و لیست گەورە دەبێت؛ ArrayListـی Javaـش گەورە دەبێت.
A fixed-length array and a list that grows درێژیی جێگیر و کە گەورە دەبێتCêIT

Asking for a box that does not exist stops both programs, but with different messages:

داواکردنی خانەیەک کە بوونی نییە هەردوو دەوەستێنێت، بەڵام بە پەیامی جیاواز:

Main.javaJAVAType in a terminalلە تێرمیناڵدا بینووسە
public class Main {
    public static void main(String[] args) {
        String[] country = new String[2];
        country[0] = "Kurdistan";
        country[1] = "Egypt";
        country[2] = "Iraq";      // there is no box number 2
    }
}
bounds.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
country = ["Kurdistan", "Egypt"]
print(country[2])

The report adds: an array stores elements of one type (homogeneous), while a Python list can mix types (heterogeneous), for example [21, "Aram", 3.5]. That is true, but in practice most Python lists also hold one kind of thing — a list of marks, a list of names — because that is easier to work with.

ڕاپۆرتەکە زیاد دەکات: یەک جۆر هەڵدەگرێت (هاوجۆر)، لە کاتێکدا دەتوانێت جۆرەکان تێکەڵ بکات (جۆراوجۆر)، بۆ نموونە [21, "Aram", 3.5]. ئەمە ڕاستە، بەڵام لە ڕاستیدا زۆربەی Pythonـیش یەک جۆر شت هەڵدەگرن — نمرە، ناو — چونکە کارکردن لەگەڵیان ئاسانترە.

Quick checkپشکنینی خێراString[] names = new String[3]; — which index is the last box?String[] names = new String[3]; — دوا خانە کام ؟

Python lists and Java arraysلیستەکانی Python و ڕیزەکەکانی Java

ArrayList: Java's growing listArrayList: لیستی گەورەبووی Java

When Java programmers need a list that grows, they use ArrayList from the library java.util. It is the closest partner of a Python list.

کاتێک Java پێویستیان بە کە گەورە بێت، ArrayList لە java.util بەکار دەهێنن. ئەمە نزیکترین هاوتای Pythonـە.

Countries.javaJAVAType in a terminalلە تێرمیناڵدا بینووسە
import java.util.ArrayList;

public class Countries {
    public static void main(String[] args) {
        ArrayList<String> country = new ArrayList<>();
        country.add("Kurdistan");
        country.add("Egypt");
        country.add("Japan");              // it grows, like append()
        System.out.println(country);
        System.out.println(country.get(0) + ", size " + country.size());
        for (String j : country) {
            System.out.println(j);
        }
    }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 1

Like Python's import: bring ArrayList in from the library.

وەک importـی : ArrayList لە بهێنە.

Lineدێڕی 5

<String> says what the list holds. It holds objects only: for whole numbers write ArrayList<Integer>.

<String> دەڵێت چی هەڵدەگرێت. تەنها هەڵدەگرێت: بۆ بنووسە ArrayList<Integer>.

Lineدێڕی 6-8

add() is Python's append().

add() هاوتای append()ـی Pythonـە.

Lineدێڕی 10

get(0) is country[0]; size() is len(country).

get(0) هاوتای country[0]ـە؛ size() هاوتای len(country)ـە.

countries.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
country = []
country.append("Kurdistan")
country.append("Egypt")
country.append("Japan")
print(country)
print(country[0] + ", size", len(country))
for j in country:
    print(j)
Quick checkپشکنینی خێراWhich ArrayList method does the job of Python's append()?کام ArrayList کاری append()ـی دەکات؟

Array vs. ArrayList in Java Tutorial - What's The Difference?Coding with John · Englishئینگلیزی · 720K viewsبینین · 32K likesلایک · Partبەشی 0:50–15:37 (ofلە 17:36)

How a fixed-size Java array and a growing ArrayList are created and used: length versus size(), adding and removing elements.

بە قەبارەی جێگیر و ArrayListـێک کە گەورە دەبێت چۆن دروست دەکرێن و بەکاردێن: length بەرامبەر size()، زیادکردن و لابردنی .

Watch 0:50-15:37: creating arrays and ArrayLists (diamond operator at 4:09), length versus size(), adding (10:40), removing (13:29) and printing (14:20): an ArrayList prints all its elements with println. Stops before his recommendation.

لە ⁦0:50⁩ تا ⁦15:37⁩ سەیر بکە: دروستکردنی و ArrayList ( diamond <> لە ⁦4:09⁩)، length بەرامبەر size()، زیادکردن ⁦(10:40)⁩، لابردن ⁦(13:29)⁩ و پیشاندان ⁦(14:20): ArrayList⁩ بە println هەموو خۆی پیشان دەدات. پێش ئامۆژگارییەکەی ڕادەوەستێت.

The report's examples as one programنموونەکانی ڕاپۆرتەکە وەک یەک بەرنامە

Putting all the corrected examples together gives one Python file and one Java file. Run them both: they print exactly the same 26 lines.

کۆکردنەوەی هەموو نموونە ڕاستکراوەکان یەک و یەک Java دەدات. هەردووکیان جێبەجێ بکە: ڕێک هەمان ⁦26⁩ دێڕ چاپ دەکەن.

compare.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
# The report's examples as one Python program (corrected)
age = 21
print("Hello World")

num = 80
if num >= 80:
    print("Excellent!")
elif num >= 50:
    print("Good.")
else:
    print("Failed!")

is_raining = True
is_snowing = False
temp = 30
if is_raining:
    if temp > 20:
        print("Ştêkî tenîk leber bike.")
    else:
        print("Cilêkî estûr leber bike.")
elif is_snowing:
    if temp > 10:
        print("Keşekey xirap nîye.")
    else:
        print("Agadarî tendrûstît be.")
else:
    print("Rojêkî xweşe!")

i = 1
while i <= 10:
    print(i)
    i += 1

for i in range(1, 11):
    print("Example", i)


def func_name():
    print("Hello World!")


func_name()

country = []
country.append("Kurdistan")
country.append("Egypt")
for j in country:
    print(j)
Main.javaJAVAType in a terminalلە تێرمیناڵدا بینووسە
// The report's examples as one Java program (corrected)
public class Main {
    public static void main(String[] args) {
        int age = 21;
        System.out.println("Hello World");

        int num = 80;
        if (num >= 80) {
            System.out.println("Excellent!");
        } else if (num >= 50) {
            System.out.println("Good.");
        } else {
            System.out.println("Failed!");
        }

        boolean isRaining = true;
        boolean isSnowing = false;
        int temp = 30;
        if (isRaining) {
            if (temp > 20) {
                System.out.println("Ştêkî tenîk leber bike.");
            } else {
                System.out.println("Cilêkî estûr leber bike.");
            }
        } else if (isSnowing) {
            if (temp > 10) {
                System.out.println("Keşekey xirap nîye.");
            } else {
                System.out.println("Agadarî tendrûstît be.");
            }
        } else {
            System.out.println("Rojêkî xweşe!");
        }

        int i = 1;
        while (i <= 10) {
            System.out.println(i);
            i++;
        }

        for (int k = 1; k <= 10; k++) {
            System.out.println("Example " + k);
        }

        funcName();

        String[] country = new String[2];
        country[0] = "Kurdistan";
        country[1] = "Egypt";
        for (String j : country) {
            System.out.println(j);
        }
    }

    private static void funcName() {
        System.out.println("Hello World!");
    }
}
Explain the codeڕوونکردنەوەی کۆدەکە
Lineدێڕی 4

int age = 21; is declared but not used, like age = 21 in Python; Java allows that.

int age = 21; ناسێنراوە بەڵام بەکار نەهاتووە، وەک age = 21 لە Pythonـدا؛ Java ڕێگەی پێ دەدات.

Lineدێڕی 41-43

In one main, i already exists, so the for loop uses a new name k (block scope).

لە یەک mainـدا i پێشتر هەیە، بۆیە ناوێکی نوێ بەکار دەهێنێت، k ().

Lineدێڕی 55-57

A private static method: only this class can call it.

private static: تەنها ئەم دەتوانێت بانگی بکات.

Quick checkپشکنینی خێراWhy does the combined Java program use k in its for loop instead of i?بۆچی Java لە k بەکار دەهێنێت نەک i؟

Python and Java side by sidePython و Java لە تەنیشت یەکەوە

Here is the lesson in three tables: how the code looks (below), how fast it runs and what each language is used for (the next two screens). How each one runs a program is in How the two languages run today.

ئەمە وانەکەیە لە سێ خشتەدا: کۆدەکە چۆن دەردەکەوێت (خوارەوە)، چەند خێرایە و هەر زمانێک بۆ چی بەکار دێت (دوو شاشەی داهاتوو). هەر یەکەیان چۆن جێبەجێ دەکات لە دوو زمانەکە ئەمڕۆ چۆن کار دەکەندایە.

Typing and syntaxجۆرداری و
TopicبابەتPythonJava
Typesجۆرەکان: no declarations; checked while running: بێ ناساندن؛ لە کاتی جێبەجێکردندا دەپشکنرێت: every variable declared with a type; checked by the compiler: هەموو بە جۆرەکەیەوە دەناسێنرێت؛ دەیپشکنێت
A variableage = 21int age = 21;
Blocks: and indentation: و braces { }کەوانەی { }
End of a statementکۆتایی end of the lineکۆتایی دێڕەکە;;
Where code livesکۆد لە کوێ دەژیanywhere in a .py fileلە هەر شوێنێکی .pyinside a class; the program starts in mainلە ناو ؛ لە main دەست پێ دەکات
Namesناوەکانsnake_case for variables and functionssnake_case بۆ و camelCase for variables and methods, PascalCase for classescamelCase بۆ و ، PascalCase بۆ
True / falseڕاست / هەڵەTrue, Falsetrue, false
Logicلۆجیکand, or, not&&, ||, !
Counting loop ژماردنfor i in range(1, 11):for (int i = 1; i <= 10; i++) {
Collectionsکۆکراوەکانlist: grows, may mix typeslist: گەورە دەبێت، دەتوانێت جۆرەکان تێکەڵ بکاتarray: fixed length, one type; ArrayList grows: درێژیی جێگیر، یەک جۆر؛ ArrayList گەورە دەبێت
Key and value pairsجووتی و dict: {"Aram": 21}HashMap<String, Integer> with put() and get()HashMap<String, Integer> بە put() و get()
Stacks and queues و a list as a stack, collections.deque as a queuelist وەک ستاک، collections.deque وەک کیووArrayDeque for bothArrayDeque بۆ هەردووکیان
Length of programsدرێژیی fewer lines (Total example: 4)دێڕی کەمتر (نموونەی ⁦Total: 4⁩)more lines (Total example: 9)دێڕی زیاتر (نموونەی ⁦Total: 9⁩)
Quick checkپشکنینی خێراWhich pair means the same thing in the two languages?کام جووت لە دوو زمانەکەدا هەمان واتای هەیە؟

Python and Java side by sidePython و Java لە تەنیشت یەکەوە

How fast?چەند خێرا؟

Speedخێرایی
TopicبابەتPythonJava
Plain loops and arithmetic و ژماردنی ساکارusually slowerزۆرجار خاوترەusually much faster, thanks to the JITزۆرجار زۆر خێراترە، بە هۆی
Heavy number workکاری قورسی ژمارەhand it to libraries written in C, such as NumPy, which run at near-C speedبیدە بە کە بە C نووسراوە، وەک NumPy، کە نزیکەی بە خێرایی C کار دەکاتwritten directly in Javaڕاستەوخۆ بە Java دەنووسرێت
Programs that wait (for a user, a network, a disk) کە چاوەڕێ دەکات (بۆ ، ، دیسک)fast enoughبە ئەندازەی پێویست خێرایەfast enoughبە ئەندازەی پێویست خێرایە
Time to write the programکاتی نووسینی usually shorterزۆرجار کورتترەusually longerزۆرجار درێژترە
Quick checkپشکنینی خێراA program spends almost all its time waiting for the user to type. Will rewriting it in Java make it much faster? نزیکەی هەموو کاتەکەی بە چاوەڕوانیی نووسینی دەبات. ئەگەر بە Java دووبارە بنووسرێتەوە زۆر خێراتر دەبێت؟

Python and Java side by sidePython و Java لە تەنیشت یەکەوە

What each language is used forهەر زمانێک بۆ چی بەکار دێت

Usesبەکارهێنان
TopicبابەتPythonJava
Typical usesبەکارهێنانە باوەکانdata science, machine learning and AI, scripts and automation, web back ends, science, teachingزانستی ، و ، و ، وێب، زانست، فێرکردنlarge business and bank systems, server back ends, Android apps, big-data tools, desktop programsسیستەمی گەورەی کار و بانک، ، Android، ئامرازەکانی گەورە، سەرمێز
Mobile apps مۆبایلnot the usual choiceهەڵبژاردنی ئاسایی نییەstill supported on Android, but Android has been Kotlin-first since 2019هێشتا لە Androidـدا پشتگیری دەکرێت، بەڵام Android لە ⁦2019⁩ـەوە سەرەتا Kotlinـە
Quick checkپشکنینی خێراWhich statement is true?کام قسە ڕاستە؟

Common mistakesهەڵە باوەکان

Most of these come from the course report or from Python habits that do not work in Java. Each message is real javac or java output.

زۆربەی ئەمانە لە ڕاپۆرتی کۆرسەکەوە یان لە خووەکانی Pythonـەوە دێن کە لە Javaـدا کار ناکەن. هەر پەیامێک ڕاستەقینەی javac یان javaـە.

Python habits and report bugs in Javaخووەکانی Python و ڕاپۆرتەکە لە Javaـدا
MistakeهەڵەWhat happensچی ڕوودەداتFixچارەسەر
System.out.printIn(...)error: cannot find symbolprintln — small Lprintln — lـی بچووک
System.out.println("Hi")error: ';' expectedEnd every statement with ;هەموو بە ; کۆتایی پێ بهێنە
boolean temp = 30;incompatible types: int cannot be converted to booleanint temp = 30;
new string[2]cannot find symbol … class stringnew String[2]
boolean isRaining = True;cannot find symbol … variable Truetrue
public class Hello saved as Main.javapublic class Hello لە Main.javaـدا هەڵگیراوەclass Hello is public, should be declared in a file named Hello.javaRename the file or the class یان ناو بنێرەوە
An if without braces, two indented linesif بێ کەوانە، دوو دێڕی بەرەوناوچووOnly the first line belongs to the ifتەنها دێڕی یەکەم سەر بە ifـەAlways use { }هەمیشە { } بەکار بهێنە
if (a == b) with two Stringsif (a == b) بۆ دوو StringCompares objects, not text: can be false for equal text بەراورد دەکات، نەک دەق: بۆ دەقی یەکسانیش دەتوانێت false بێتa.equals(b)
names[names.length]ArrayIndexOutOfBoundsExceptionThe last index is length - 1دوا length - 1ـە
elif in Javaelif لە JavaـداNot a Java wordوشەیەکی Java نییەelse if

Two of these deserve a closer look. Without braces, the indentation lies: only the first line is inside the if.

دووان لەمانە شایەنی سەیرکردنی نزیکترن. بەبێ کەوانە، درۆ دەکات: تەنها دێڕی یەکەم لە ناو ifـدایە.

Main.java (inside main)JAVAType in a terminalلە تێرمیناڵدا بینووسە
int x = -5;
if (x > 0)
    System.out.println("positive");
    System.out.println("checked");

And == on two Strings asks “is this the same object?”, not “is this the same text?”. Use .equals() for text:

هەروەها == لەسەر دوو String دەپرسێت «ئایا ئەمە هەمان ە؟»، نەک «ئایا هەمان دەقە؟». بۆ دەق .equals() بەکار بهێنە:

Main.java (inside main)JAVAType in a terminalلە تێرمیناڵدا بینووسە
String a = "loop";
String b = new String("loop");
System.out.println(a == b);        // are they the same object?
System.out.println(a.equals(b));   // do they hold the same text?

Other tracks: MATLAB today, perhaps Java and C# laterڕێڕەوەکانی تر: MATLAB ئەمڕۆ، لەوانەیە Java و ⁦C#⁩ دواتر

This course is built so that other languages can join it. The shared chapters (what programming is, algorithms and flowcharts) teach ideas without any language's code, and each technology track teaches the same ideas through one language. Today there are two tracks: Python, which you have just finished, and MATLAB, the “matrix laboratory” that engineers and scientists use for calculations and plots. A Java or C# track may come later with the same chapters; in a Java track this lesson would become “Java next to Python”.

ئەم کۆرسە وا دروست کراوە کە زمانی تر بتوانن بێنە ناوی. بەشە هاوبەشەکان ( چییە، و ) بیرۆکەکان بەبێ کۆدی هیچ زمانێک فێر دەکەن و هەر ڕێڕەوێکی تەکنەلۆجی هەمان بیرۆکەکان لە ڕێگەی یەک زمانەوە فێر دەکات. ئەمڕۆ دوو ڕێڕەو هەیە: Python (ئەوەی ئێستا تەواوت کرد) و MATLAB، «تاقیگەی »، کە ئەندازیاران و زانایان بۆ ژماردن و بەکاری دەهێنن. لەوانەیە دواتر ڕێڕەوێکی Java یان ⁦C#⁩ بە هەمان بەشەکان بێت؛ لە ڕێڕەوی Javaـدا ئەم وانەیە دەبێت بە «Java لە تەنیشت Pythonـەوە».

C# (said “C sharp”) is Microsoft's language for the .NET platform. It belongs to the same family as Java: braces, ;, static types and classes. Once you can read the Java in this lesson, C# will look familiar:

⁦C#⁩ (دەخوێنرێتەوە «سی شارپ») زمانی Microsoftـە بۆ ⁦.NET⁩. سەر بە هەمان خێزانی Javaـیە: کەوانە، ;، جۆری جێگیر و . کاتێک بتوانیت Javaـی ئەم وانەیە بخوێنیتەوە، ⁦C#⁩ ناسراو دەردەکەوێت:

The same line in three languagesهەمان دێڕ لە سێ زماندا
LanguageزمانPrint one lineچاپکردنی یەک دێڕ
Pythonprint("Hello, World")
JavaSystem.out.println("Hello, World");
C#Console.WriteLine("Hello, World");
Quick checkپشکنینی خێراWhich line prints one line of text in C#?کام دێڕ لە ⁦C#⁩ـدا دێڕێک دەق چاپ دەکات؟

Exercisesڕاهێنانەکان

Exerciseڕاهێنان1. Fix the report's Java⁦1. Java⁩ـی ڕاپۆرتەکە چاک بکەرەوە

These lines are typed as in the course report. javac reports three errors. Explain each one and write the corrected lines.

ئەم دێڕانە وەک ڕاپۆرتی کۆرسەکە نووسراون. javac سێ ڕاپۆرت دەکات. هەر یەکێکیان ڕوون بکەرەوە و دێڕە ڕاستکراوەکان بنووسە.

Main.javaJAVAType in a terminalلە تێرمیناڵدا بینووسە
class Main {
  public static void main(String[] args) {
    int age = 21;
    System.out.printIn("Hello World");
    boolean temp = 30;
    String[] country = new string[2];
  }
}
Show answerوەڵامەکە پیشان بدە
javac Main.javajavac بۆ ⁦Main.java⁩
Main.java:4: error: cannot find symbol
    System.out.printIn("Hello World");
              ^
  symbol:   method printIn(String)
  location: variable out of type PrintStream
Main.java:5: error: incompatible types: int cannot be converted to boolean
    boolean temp = 30;
                   ^
Main.java:6: error: cannot find symbol
    String[] country = new string[2];
                           ^
  symbol:   class string
  location: class Main
3 errors
  • Line 4: printIn does not exist — println.
  • Line 5: a temperature is a whole number — int temp = 30;.
  • Line 6: Java is case-sensitive — new String[2].
  • دێڕی 4: printIn بوونی نییە — println.
  • دێڕی 5: پلەی گەرمی — int temp = 30;.
  • دێڕی ⁦6: Java⁩ — new String[2].
Main.java (lines 4-6, fixed)JAVAType in a terminalلە تێرمیناڵدا بینووسە
    System.out.println("Hello World");
    int temp = 30;
    String[] country = new String[2];
Exerciseڕاهێنان2. Count down in Java2. لە Javaـدا بەرەو خوار بژمێرە

Translate this Python loop into a Java for loop: for i in range(10, 0, -2): print(i).

ئەم Python وەربگێڕە بۆ لە Javaـدا: for i in range(10, 0, -2): print(i).

Hintئاماژە

Write the start, the condition and the step of the for header.

دەستپێک، و هەنگاوی سەرەی for بنووسە.

Show answerوەڵامەکە پیشان بدە
Main.java (inside main)JAVAType in a terminalلە تێرمیناڵدا بینووسە
for (int i = 10; i > 0; i -= 2) {
    System.out.println(i);
}

Start at 10, keep going while i > 0 (Python's stop value 0 is not included), and step with i -= 2.

لە ⁦10⁩ـەوە دەست پێ بکە، تا i > 0 بەردەوام بە ( وەستانی Python، واتە 0، ناگیرێتەوە) و بە i -= 2 هەنگاو بنێ.

Exerciseڕاهێنان3. Positive, negative or zero3. موجەب، سالب یان سفر

Write an if-else-if ladder in Java that prints positive, negative or zero for int number = -7;. Then write the same in Python.

پەیژەیەکی ⁦if-else-if⁩ لە Javaـدا بنووسە کە بۆ int number = -7; positive، negative یان zero چاپ بکات. پاشان هەمان شت بە Python بنووسە.

Show answerوەڵامەکە پیشان بدە
Main.java (inside main)JAVAType in a terminalلە تێرمیناڵدا بینووسە
int number = -7;
if (number > 0) {
    System.out.println("positive");
} else if (number < 0) {
    System.out.println("negative");
} else {
    System.out.println("zero");
}
sign.pyPYTHONType in a terminalلە تێرمیناڵدا بینووسە
number = -7
if number > 0:
    print("positive")
elif number < 0:
    print("negative")
else:
    print("zero")
Exerciseڕاهێنان4. Predict a do-while4. پێشبینیی ⁦do-while⁩

What does this print? int n = 3; do { System.out.println("n is " + n); n++; } while (n < 5);

ئەمە چی چاپ دەکات؟ int n = 3; do { System.out.println("n is " + n); n++; } while (n < 5);

Show answerوەڵامەکە پیشان بدە
Main.java (inside main)JAVAType in a terminalلە تێرمیناڵدا بینووسە
int n = 3;
do {
    System.out.println("n is " + n);
    n++;
} while (n < 5);

The body runs with 3 and with 4. After the second round n is 5, 5 < 5 is false and the loop stops. With int n = 10; it would still print once (see the do-while screen).

جەستەکە بە 3 و بە 4 جێبەجێ دەبێت. دوای جاری دووەم n دەبێت بە 5، 5 < 5 هەڵەیە و دەوەستێت. بە int n = 10; هێشتا یەک جار چاپ دەکات (بڕوانە شاشەی ⁦do-while⁩).

Exerciseڕاهێنان5. Spot the language5. زمانەکە بناسەوە

For each line say whether it is Python, Java or neither: (a) int[] a = {1, 2}; (b) a = [1, 2] (c) if x > 0 { (d) for (String s : names) { (e) elif (x > 0):

بۆ هەر دێڕێک بڵێ Pythonـە، Javaـیە یان هیچیان: (أ) int[] a = {1, 2}; (ب) a = [1, 2] (ج) if x > 0 { (د) for (String s : names) { (هـ) elif (x > 0):

Show answerوەڵامەکە پیشان بدە
  • (a) Java: an array of two int values.
  • (b) Python: a list.
  • (c) Neither: Java needs if (x > 0) {, Python needs if x > 0:.
  • (d) Java: an enhanced for over an array or list of Strings.
  • (e) Python (legal, though the parentheses are not needed).
  • (أ) Java: لە دوو int.
  • (ب) Python: ئەمە .
  • (ج) هیچیان: Java پێویستی بە if (x > 0) {ـە، Python پێویستی بە if x > 0:ـە.
  • (د) Java: forـی پەرەپێدراو بە ناو یان Stringـدا.
  • (هـ) Python (دروستە، هەرچەندە کەوانەکان پێویست نین).
Quick checkپشکنینی خێراWhich Python habit breaks a Java program?کام خووی Python Java تێک دەدات؟

Summaryپوختە

  • A Java program lives in a class; it starts in public static void main(String[] args); System.out.println prints a line.
  • Java declares types (int age = 21;), ends statements with ; and marks blocks with { }; Python uses neither declarations nor braces.
  • javac compiles to bytecode in .class files and finds compile-time errors; java runs the bytecode on the JVM. Python compiles to bytecode by itself on every run.
  • Java has else if, a three-part for, a for-each loop and do … while; Python has elif, for … in range() and while True + break.
  • A Java array has a fixed length and one type; ArrayList grows like a Python list.
  • The course report's Java was corrected: println, semicolons, int temp, String, a declared isSnowing; Android is Kotlin-first since 2019.
  • Java لە ناو دەژی؛ لە public static void main(String[] args) دەست پێ دەکات؛ System.out.println دێڕێک چاپ دەکات.
  • Java جۆرەکان دەناسێنێت (int age = 21;)، بە ; کۆتایی پێ دەهێنێت و بە { } دیاری دەکات؛ نە ناساندن و نە کەوانە بەکار دەهێنێت.
  • javac بۆ لە .classـدا کۆمپایل دەکات و دەدۆزێتەوە؛ java لەسەر JVM جێبەجێ دەکات. لە هەموو جێبەجێکردنێکدا خۆی دەیکات بە .
  • Java else if، forـی سێ بەشی، ⁦for-each⁩ و do … whileـی هەیە؛ elif، for … in range() و while True + breakـی هەیە.
  • Java درێژییەکی جێگیر و یەک جۆری هەیە؛ ArrayList وەک گەورە دەبێت.
  • Javaـی ڕاپۆرتی کۆرسەکە ڕاست کرایەوە: println، ، int temp، String، isSnowingـی ناسێنراو؛ Android لە ⁦2019⁩ـەوە سەرەتا Kotlinـە.
Review questionsپرسیارەکانی پێداچوونەوە
What is the difference between javac and java?جیاوازیی نێوان javac و java چییە؟

javac compiles .java source files into .class bytecode; java starts the JVM, which runs that bytecode.

javac سەرچاوەی .java دەکات بە .class؛ java JVM دەست پێ دەکات کە ئەو جێبەجێ دەکات.

Why is String written with a capital S?بۆچی String بە Sـی گەورە دەنووسرێت؟

It is a class, not a primitive type, and Java is case-sensitive: string is an unknown name.

، نەک . هەروەها Java : string ناوێکی نەناسراوە.

How do you write a do-while loop in Python?چۆن خولێکی ⁦do-while⁩ لە Pythonـدا دەنووسیت؟

With while True: and, at the end of the body, if not condition: break.

بە while True: و لە کۆتایی جەستەکەدا if not condition: break.

When does each language find a misspelt variable name?هەر زمانێک کەی ناوی گۆڕاوێکی هەڵە نووسراو دەدۆزێتەوە؟

Java: at compile time, before anything runs. Python: only when the line with the name runs.

Java: لە کاتی کۆمپایلکردندا، پێش ئەوەی هیچ جێبەجێ بێت. : تەنها کاتێک ئەو دێڕەی ناوەکەی تێدایە جێبەجێ دەبێت.

You finished the Python trackڕێڕەوی Pythonـت تەواو کرد

Well done! This is the last lesson of the Python track. Here is what you learned, chapter by chapter; each chapter name opens its first lesson.

دەستخۆش! ئەمە دوا وانەی ڕێڕەوی Pythonـە. ئەمە ئەوەیە کە فێری بوویت، بەش بە بەش؛ ناوی هەر بەشێک یەکەم وانەکەی دەکاتەوە.

The course in one tableکۆرسەکە لە یەک خشتەدا
ChapterبەشWhat you learnedفێری چی بوویت
Programs and programming languagesبەشی بەرنامەکان و زمانەکانی بەرنامەسازیwhat a program is, high- and low-level languages, compilers and interpreters چییە، و ، و
Solving problems step by stepبەشی چارەسەرکردنی کێشە هەنگاو بە هەنگاوalgorithms, pseudocode, flowcharts, trace tables, planning a project، ، ، ، پلاندانانی
Getting started with Pythonبەشی دەستپێکردن لەگەڵ Pythoninstalling Python, the shell and scripts, print(), comments, reading error messagesدامەزراندنی Python، و ، ⁦print()⁩، ، خوێندنەوەی پەیامی
Variables, data and expressionsبەشی گۆڕاوەکان، دراوە و دەربڕینەکانvariables and types, operators, input and output, f-strings و جۆرەکان، ، و ،
Making decisionsبەشی بڕیاردانif, elif, else, and, or, not, nested ifif، elif، else، and، or، not،
Stringsبەشی زنجیرەنووسەکانindexing, slicing, string methods, comparing text، ، ، بەراوردکردنی دەق
Repeating code: loopsبەشی دووبارەکردنەوەی کۆد: خولەکانwhile, for and range(), break and continue, nested loops and patternswhile، for و ⁦range()⁩، break و continue، و شێوەکان
Functionsبەشی کردارەکانdef and return, arguments, scope, modules, recursiondef و return، ، ، ،
Listsبەشی لیستەکانcreating, changing and copying lists, sorting, two-dimensional listsدروستکردن، گۆڕین و کۆپیکردنی ، ،
More data and safer programsبەشی دراوەی زیاتر و بەرنامەکانی سەلامەتترtuples, sets, dictionaries, try and except, reading and writing files, pickle، ، ، try و except، خوێندنەوە و نووسینی ، pickle
Data structures and algorithmsبەشی پێکهاتەکانی دراوە و ئەلگۆریزمەکانstacks, queues and deques, bubble sort and insertion sort, binary search and hashing، و ، و ، و هاشکردن
Projects and next stepsبەشی پڕۆژەکان و هەنگاوەکانی داهاتووthe binary-to-decimal converter, the Mixed Letters game, Python next to Javaگۆڕەری بۆ ، یاریی پیتە تێکەڵەکان، Python لە تەنیشت Javaـەوە

What to learn nextدواتر فێری چی ببیت

Three CêIT courses build directly on what you learned here:

سێ کۆرسی CêIT ڕاستەوخۆ لەسەر ئەوەی لێرە فێری بوویت بنیات دەنێن:

Whichever you choose, the habits from this course go with you: plan before you code, test every branch, read error messages calmly, and write code that people can read.

هەر کامێکیان هەڵبژێریت، خووەکانی ئەم کۆرسە لەگەڵت دێن: پێش کۆدنووسین پلان دابنێ، هەموو لقێک تاقی بکەرەوە، پەیامی بە ئارامی بخوێنەرەوە و کۆدێک بنووسە کە خەڵک بتوانێت بیخوێنێتەوە.

Videoڤیدیۆ

Watch a videoسەیری ڤیدیۆیەک بکە

A video that viewers liked a lot and praised in their comments, chosen for this lesson.ڤیدیۆیەک کە بینەران زۆریان پێ خۆش بووە و لە کۆمێنتەکانیاندا ستایشیان کردووە، بۆ ئەم وانەیە هەڵبژێردراوە.

Python in 8 minutes (compared to Java)NeetCode · Englishئینگلیزی · 93K viewsبینین · 1.7K likesلایک

The same 'print some text' program in Java and in Python: Java needs a class and a main method, Python one line.

هەمان بە و بە ، کە دەقێک پیشان دەدات: پێویستی بە و main هەیە، تەنها یەک دێڕ.

Watch all 7:50: printing (Java 0:00, Python 2:00), storing data (2:30, 3:40) and loops (4:30, 6:00). It also uses a Java HashMap, which this lesson does not teach.

هەموو ڤیدیۆکە ⁦(7:50)⁩ سەیر بکە: پیشاندانی دەق ( ⁦0:00⁩، ⁦2:00⁩)، هەڵگرتنی (⁦2:30⁩، ⁦3:40⁩) و (⁦4:30⁩، ⁦6:00⁩). هەروەها HashMap لە بەکاردەهێنێت، کە ئەم وانەیە فێری ناکات.

Lesson complete!وانەکە تەواو بوو!

Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.

Key termsزاراوە سەرەکییەکان

References and further readingسەرچاوەکان و خوێندنەوەی زیاتر

This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.