Java 4: Review
Java 5
Array
File name: Java4
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package java4;
/**
*
* @author DELL
*/
public class Java4 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String[] nama = new String[6];
nama[0] = "Caca";
nama[1] = "Cece";
nama[2] = "Cici";
nama[3] = "Coco";
nama[4] = "Cucu";
nama[5] = "Rois";
// mengambil data array
System.out.println(nama[4]);
}
}
//https://www.petanikode.com/java-array/
#####
File name: Java4A
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package java4;
import java.util.Scanner;
/**
*
* @author DELL
*/
public class Java4A {
public static void main(String[] args) {
// membuat array buah-buahan
String[] buah = new String[5];
// membuat scanner
Scanner scan = new Scanner(System.in);
// mengisi data ke array
for( int i = 0; i < buah.length; i++ ){
System.out.print("Buah ke-" + i + ": ");
buah[i] = scan.nextLine();
}
System.out.println("---------------------------");
// menampilkan semua isi array
for( String b : buah ){
System.out.println(b);
}
}
}
##
Java4C
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package java4;
/**
*
* @author DELL
*/
public class Java4B {
public static void main(String[] args) {
String[] nama = {"Tata", "Tete", "Titi", "Toto", "Tutu", "Rois"};
// mengambil data array
System.out.println(nama[5]);
}
}
##
Java4C
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package java4;
/**
*
* @author DELL
*/
public class Java4C {
// membuat fungsi ucapSalam()
static void ucapSalam(){
System.out.println("Selamat Pagi");
}
static void ucapSalami(){
System.out.println("Selamat Siang");
}
// membuat fungsi main()
public static void main(String[] args){
// memanggil/eksekusi fungsi ucapSalam()
ucapSalam();
ucapSalami();
}
}
//https://www.petanikode.com/java-prosedur-dan-fungsi/
//Sisanya bersambung...
"Boleh Konsultasi Masuk Jurusan Sistem Informasi via IG atau Tiktok."
|
Tips Skripsi Program Studi Sistem Informasi |
|
No comments:
Post a Comment