Comp 110 Common Mistakes on Problem Sets

Some of these items you will not need to worry about in your first few programs, but they'll come in handy soon.

  • Mispelling difficult words - the grader is very picky

  • Using specific words in phrases - for example if the assignment asks for the output to have a certain word in it, make sure it does!

  • Forgetting a ; at the end of a line of code

  • Using the wrong type (e.g. Using an int instead of a double)

  • Forgetting to enclose your code in brackets { }

  • Inconsistent capitalization of variable names, method names, etc.

  • Trying to use the 'new’ keyword when initializing primitive (int, double, boolean, char) variables. E.g.: int i = new 0;

  • Confusing parameter/argument syntax

  • Instantiating Double instead of double, Boolean instead of boolean, etc. (careful: unlike int, double, char, etc. String is capitalized)

  • When assigning a value to a variable the variable goes on the left and the value of the right of the =. (ex. i = 2; NOT 2 = i;)

  • You cannot use a variable outside of the brackets {} in which it is declared

  • Make sure to initialize (assign a value to) your variables before using them

  • Not realizing that “=” is the assignment operator and it does not mean something is equal to something

  • The relational operators (==, !=, >, <, <=, >=) can only used to compare primitive types (boolean, int, double, char) NOT string

  • Infinite while loops due to not incrementing its counter variable within the body of the loop each iteration (also check if the counter variable is being incremented inside an if statement within the loop!)

  • Placing a semicolon after the parenthesis of a loop or if statement I.e. if (); {}

  • Forgetting to use curly braces around if/loop bodies