Beispiel #1
0
 public static void main(String[] args) {
   Sarray c = new Sarray(10);
   System.out.println("Here's the array: " + c.toString());
   System.out.println("The size is " + c.size());
   System.out.println("Grab the element at index three: " + c.get(3));
   System.out.println("Print out of bounds error: " + c.set(11, 100));
 }
 /*-----------------MAIN-----------*/
 public static void main(String[] args) {
   Sarray s = new Sarray();
   System.out.println(s);
   s.add("hola");
   System.out.println(s);
   System.out.println(s.size());
   s.add(4, "mundo");
   System.out.println(s);
   // s.add(99,"mundo");
   // System.out.println(s);
   System.out.println(s.size());
   System.out.println();
   System.out.println();
   System.out.println(s.get(0));
   System.out.println(s);
   s.remove(0);
   System.out.println(s);
   System.out.println();
   System.out.println();
   System.out.println();
   s.set(0, "hola");
   System.out.println(s);
 }
Beispiel #3
0
 /*------------ Main -------------*/
 public static void main(String[] args) {
   Sarray s = new Sarray();
   s.add("toy");
   s.add("door");
   System.out.println(s);
   s.add("poor");
   s.add("shore");
   System.out.println(s);
   s.add("lore");
   System.out.println(s);
   try {
     s.add(5, "more");
     System.out.println("it's all good");
   } catch (Exception e) {
     System.out.println("Error: " + e);
   }
   System.out.println(s);
   System.out.println(s.size());
 }