This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Mahasiswa { | |
public string NIM; | |
public string Nama; | |
public int Angkatan; | |
public Mahasiswa(string nim, string nama, int angkatan) { | |
// Variable assignment. | |
NIM = nim; | |
Nama = nama; | |
Angkatan = angkatan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Mahasiswa { | |
public string NIM; | |
public string Nama; | |
public int Angkatan; | |
public Mahasiswa(string nim, string nama, int angkatan) { | |
// Variable assignment. | |
NIM = nim; | |
Nama = nama; | |
Angkatan = angkatan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inisialisasi objek dari class Mahasiswa. | |
Mahasiswa mhs = new Mahasiswa("123456", "Ivan", 2023); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Mahasiswa { | |
public string NIM; | |
public string Nama; | |
public int Angkatan; | |
public Mahasiswa(string nim, string nama, int angkatan) { | |
// Variable assignment. | |
NIM = nim; | |
Nama = nama; | |
Angkatan = angkatan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorial(num): | |
if num == 1: | |
return num | |
return num * factorial(num - 1) | |
# Scenario: | |
# num = 6 | |
# 6 * factorial(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int factorial(int num) { | |
if(num == 1) { | |
return num; | |
} | |
return num * factorial(num - 1); | |
} | |
// Scenario: | |
// num = 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_banner(): | |
print("==========================") | |
print("Contoh nama program") | |
print("Oleh Ivan K") | |
print("==========================") | |
# WARNING: Fungsi ini tidak akan pernah dipakai | |
# karena fungsi yang sama dengan jumlah parameter yang | |
# sama telah didefinisikan setelah fungsi ini. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void printBanner() { | |
System.out.println("============================="); | |
System.out.println("Contoh nama program"); | |
System.out.println("Oleh Ivan K"); | |
System.out.println("============================="); | |
} | |
static void printBanner(String nama) { | |
System.out.println("============================="); | |
System.out.println("Contoh nama program"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matrix = [] | |
matrix.append([1, 2]) | |
matrix.append([3, 4]) | |
print(matrix[1][0]) | |
# Output: | |
# 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int[][] matrix = new int[2][2]; | |
matrix[0][0] = 1; | |
matrix[0][1] = 2; | |
matrix[1][0] = 3; | |
matrix[1][1] = 4; | |
System.out.println(matrix[1][0]); | |
// Output: |