Arrays vs ArrayLists vs Strings

Array List String
Create //size must be known at creation
type example_array[] = new type[n];
//type must not be a primitave use Integer NOT int
ArrayList<type> nums = new ArrayList<type>();
String example_string = new String();
Add Elements example_array.add(thing) example_string + thing
Get Size example_array.length example_list.size() example_string.length()
Get nth Item example_array[n] example_list.get(n) example_string.substring(n, n+1)
Set nth Item example_array.[n] = thing example_list.set(thing)
Size fixed variable variable
Data types Objects and Primitives Objects String
Remove nth Element example_array.remove(n)
Example int[] x = new int[0];//create a new array of size 10, all items start as value 0
x[0] = 7; //set the first index to 7
if (x[0] == 10) return; //check if the item at index 0 is 10
System.out.println(x.length); //print the length of an array
ArrayList<Integer> nums = new ArrayList<Integer>();
example_array.add(3);
example_array.add(7);
example_array.add(9); //the list is now 3, 7, 9
System.out.println(x.size); //print the length of the list (3)
example_array.remove(0); //the list is now 7, 9
String s = "car";
s += " dog";
System.out.println(s.length()); //print the length of the string (7)
System.out.println(s.substring(2)); //prints "r dog"
System.out.println(s.substring(2, 3)); //prints "r"

1 Point Penalty

1 Point Pentalty v) Array/collection access confusion ([] get)
1 Point Pentalty w) Extraneous code that causes side-effect(e.g.,writing to output,failure to compile)
1 Point Pentalty x) Local variables used but none declared
1 Point Pentalty y) Destruction of persistent data (e.g., changing value referenced by parameter)
1 Point Pentalty z) Void method or constructor that returns a value

No Penalty

No Pentalty Extraneous code with no side-effect(e.g.,precondition check,no-op)
No Pentalty Spelling/case discrepancies where there is no ambiguity*
No Pentalty Local variable not declared provided other variables are declared in some part
No Pentalty private or public qualifier on a local variable
No Pentalty Missing public qualifier on class or constructor header
No Pentalty Keyword used as an identifier
No Pentalty Common mathematical symbols used for operators (× • ÷ < > <> ≠)
No Pentalty []vs.()vs.<>
No Pentalty = instead of == and vice versa
No Pentalty length/size confusion for array, String, List, or ArrayList; with or without ( )
No Pentalty Extraneous [] when referencing entire array
No Pentalty [i,j] instead of [i][j]
No Pentalty Extraneous size in array declaration,e.g.,int[size] nums=new int[size];
No Pentalty Missing; where structure clearly conveys intent
No Pentalty Missing {} where indentation clearly conveys intent
No Pentalty Missing() o nparameter-less method or construct or invocations
No Pentalty Missing ( ) around if or while conditions

Make sure you earn points!

If you are told to call a function then you should call a function.
Use the parameters in your function.
Iterate through your data, if applicable. Often it will be a string, array, or arrayList.
Create your data correctly, often it will be an array or arrayList.
Return what is asked to return.
Constructors are generally assigning variables to private global variables.