1. menggunakan bahasa java.
public class Array {
public static void main(String args[]) {
String[] buah = {"Aku", "Kamu", "dan", "Dia", ":("};
for( int i = 0; i < buah.length; i++ ){
System.out.print("Buah ke-" + i + ": " + buah[i] + "\n");
}
2. update element ke 18 , sebagai contoh disini element ke 3
buah[3] = ("Selamanya");
untuk test bisa apa gk copas ke link ini https://www.tutorialspoint.com/compile_java_online.php
Berikut jawabannya saya sertakan dalam bahasa Java:
public class Main
{
private static void printEdibleList(String[] fruitVegetable)
for (String fv : fruitVegetable) {
System.out.println(fv);
private static String[] edit18ThElement(String[] edible)
edible[17] = "Raspberry";
return edible;
public static void main(String[] args) {
//20 Fruits and Vegetables
String[] edibleFruitAndVegetable =
"Cucumber","Corn","Apple","Pear","Orange",
"Mandarin","Grape","Guava","Strawberries","Kiwi",
"Tomato", "Banana","Watermelon","Mango","Pineapple",
"Coconut","Bean","Cabbage","Carrot","Eggplant"
};
System.out.println("Before Edit List:");
printEdibleList(edibleFruitAndVegetable);
edibleFruitAndVegetable = edit18ThElement(edibleFruitAndVegetable);
System.out.println("\nAfter Edit List:");
Code dapat dicoba disini: https://onlinegdb.com/H1nA8hOB4
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
1. menggunakan bahasa java.
public class Array {
public static void main(String args[]) {
String[] buah = {"Aku", "Kamu", "dan", "Dia", ":("};
for( int i = 0; i < buah.length; i++ ){
System.out.print("Buah ke-" + i + ": " + buah[i] + "\n");
}
}
}
2. update element ke 18 , sebagai contoh disini element ke 3
public class Array {
public static void main(String args[]) {
String[] buah = {"Aku", "Kamu", "dan", "Dia", ":("};
for( int i = 0; i < buah.length; i++ ){
System.out.print("Buah ke-" + i + ": " + buah[i] + "\n");
buah[3] = ("Selamanya");
}
}
}
untuk test bisa apa gk copas ke link ini https://www.tutorialspoint.com/compile_java_online.php
Berikut jawabannya saya sertakan dalam bahasa Java:
public class Main
{
private static void printEdibleList(String[] fruitVegetable)
{
for (String fv : fruitVegetable) {
System.out.println(fv);
}
}
private static String[] edit18ThElement(String[] edible)
{
edible[17] = "Raspberry";
return edible;
}
public static void main(String[] args) {
//20 Fruits and Vegetables
String[] edibleFruitAndVegetable =
{
"Cucumber","Corn","Apple","Pear","Orange",
"Mandarin","Grape","Guava","Strawberries","Kiwi",
"Tomato", "Banana","Watermelon","Mango","Pineapple",
"Coconut","Bean","Cabbage","Carrot","Eggplant"
};
System.out.println("Before Edit List:");
printEdibleList(edibleFruitAndVegetable);
edibleFruitAndVegetable = edit18ThElement(edibleFruitAndVegetable);
System.out.println("\nAfter Edit List:");
printEdibleList(edibleFruitAndVegetable);
}
}
Code dapat dicoba disini: https://onlinegdb.com/H1nA8hOB4