Skip to content

Instantly share code, notes, and snippets.

View affandes's full-sized avatar
💜
Lovin n Codin

Muhammad Affandes affandes

💜
Lovin n Codin
View GitHub Profile
@affandes
affandes / cuboid.csv
Created April 22, 2024 04:36
Data contoh untuk kebutuhan membaca data untuk latihan pemrograman.
Edge A Edge B Edge C
39.76 52.18 64.78
22.48 48.65 44.65
64.12 24.47 56.33
49.55 79.84 84.36
62.41 42.53 67.90
77.35 59.27 61.03
48.77 61.44 23.23
29.16 37.16 59.92
34.37 52.36 62.53
@affandes
affandes / Stack.java
Created January 2, 2024 02:28
Contoh kode program Stack menggunakan Generic untuk berbagai tipe data
public class Stack<T> {
public T[] data;
public int top;
public Stack(Class<T> c, int n) {
this.data = (T[]) Array.newInstance(c, n);
this.top = 0;
}
@affandes
affandes / Stack.java
Created January 2, 2024 02:25
Contoh kode program Stack dengan tipe data class Mahasiswa
public class Stack {
public Mahasiswa[] data; // tipe data Mahasiswa
public int top;
public Stack(int n) {
this.data = new Mahasiswa[n]; // tipe data Mahasiswa
this.top = 0;
}
@affandes
affandes / Stack.java
Created January 2, 2024 02:23
Contoh kode program Stack dengan tipe data String
public class Stack {
public String[] data; // tipe data String
public int top;
public Stack(int n) {
this.data = new String[n]; // tipe data String
this.top = 0;
}
@affandes
affandes / Stack.java
Created January 2, 2024 02:21
Contoh kode program Stack dengan tipe data long
public class Stack {
public long[] data; // tipe data long
public int top;
public Stack(int n) {
this.data = new long[n]; // tipe data long
this.top = 0;
}
@affandes
affandes / Stack.java
Created January 2, 2024 02:18
Contoh kode program Stack dengan tipe data int
public class Stack {
public int[] data; // tipe data int
public int top;
public Stack(int n) {
this.data = new int[n]; // tipe data int
this.top = 0;
}
@affandes
affandes / Main.java
Created January 2, 2024 02:10
Contoh kode program untuk membuat Stack menggunakan class Stack yang dibuat sendiri
public class Main {
public static void main(String[] args) {
Stack stack = new Stack(5);
stack.push(24);
stack.push(9);
stack.push(12);
System.out.println(stack.pop());
}
}
@affandes
affandes / Stack.java
Last active January 2, 2024 02:09
Contoh membuat class Stack sendiri pada Java
public class Stack {
public int[] data;
public int top;
public Stack(int n) {
this.data = new int[n];
this.top = 0;
}
@affandes
affandes / Mahasiswa.java
Created January 2, 2024 02:04
Contoh class Mahasiswa yang digunakan pada Stack
public class Mahasiswa {
public String nama;
public String nim;
public Mahasiswa(String nama, String nim) {
this.nama = nama;
this.nim = nim;
}
@affandes
affandes / Main.java
Created January 2, 2024 02:02
Contoh kode program membuat Stack dengan tipe data Mahasiswa
public class Main {
public static void main(String[] args) {
Stack<Mahasiswa> stack = new Stack<>();
stack.push(new Mahasiswa("Andi","123"));
stack.push(new Mahasiswa("Budi","234"));
System.out.println(stack.pop());
}
}