Arrays
Some Practice Array Stuff :)
import java.util.ArrayList;
public class MeditationSuggestions {
public static void main(String[] args) {
testing(null);
}
public static void testing(String[] args) {
// defining breathing exercises in meditation as an empty arraylist
ArrayList<String> meditation = new ArrayList<String>(Arrays.asList("Box Breathing", "Belly Breathing", "4-7-8"));
System.out.println("Original array:");
System.out.println("" + meditation);
System.out.println(" - " + meditation.size() + " techniques");
System.out.println(" -------------------------------------------------- ");
// Add 3 breathing exercises to meditation
meditation.add("Rainbow Breathing");
meditation.add("5 Finger Breathing");
meditation.add("Diaphragm Breathing");
// Printing result
System.out.println("Example with adding to array:");
System.out.println("" + meditation);
System.out.println(" - " + meditation.size() + " techniques");
System.out.println(" -------------------------------------------------- ");
// Remove previously added exercises...
meditation.remove("Rainbow Breathing");
meditation.remove("5 Finger Breathing");
meditation.remove("Diaphragm Breathing");
// Printing result
System.out.println("Example with removing from array:");
System.out.println("" + meditation);
System.out.println(" - " + meditation.size() + " techniques");
System.out.println(" -------------------------------------------------- ");
// Clearing all items in list
meditation.clear();
// Printing Result
System.out.println("Example with clearing array:");
System.out.println("" + meditation);
System.out.println(" - " + meditation.size() + " techniques");
System.out.println("Is array empty? True or False: " + meditation.isEmpty());
System.out.println(" -------------------------------------------------- ");
if (meditation.isEmpty() == true) {
meditation.add("Box breathing");
meditation.add("Belly breathing");
meditation.add("4-7-8");
}
System.out.println("Example with adding back to the array:");
System.out.println("" + meditation);
System.out.println(" - " + meditation.size() + " techniques");
System.out.println(" -------------------------------------------------- ");
}
}
MeditationSuggestions.main(null);