Common errors
Upcoming SlideShare
Loading in...5
×
 

Common errors

on

  • 2,355 views

 

Statistics

Views

Total Views
2,355
Views on SlideShare
59
Embed Views
2,296

Actions

Likes
0
Downloads
6
Comments
0

1 Embed 2,296

https://myasucourses.asu.edu 2296

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Common errors Common errors Presentation Transcript

  • Common Errors and Solutions CST200 – Week 1: Common Errors when Starting to write and compile Java Code Instructor: Andreea Molnar
  • Outline • Disclaimer • Names • Brackets • Semicolons
  • Error Category
  • Names
  • Names (e.g. class names, variable names, method names) are a single string!
  • public class Hello World { } Is the class name Hello or World?
  • public class Hello World { } After the first string –Hello – a bracket is expected.
  • public class Hello World { }
  • public class Hello World { }
  • public class HelloWorld { } public class Hello { } public class World { }
  • Keep in mind, it is not only class names, variable names and method names have to be composed of a single connected string.
  • public class HelloWorld { public static void main(String [] args) { int Britteny Spears; } }
  • public class HelloWorld { public static void main(String [] args) { int Britteny Spears; } } After the first string –Brittney – a ; is expected.
  • public class HelloWorld { public static void main(String [] args) { int Britteny Spears; } }
  • public class HelloWorld { public static void main(String [] args) { int BrittenySpears; int Britteny; int Spears; } }
  • public class HelloWorld { public static void main(String [] args) { //this is the best int brittenySpears; int britteny; int spears; } }
  • Brackets
  • Every open bracket has to be closed in the program!!!
  • As a rule of thumb check that every bracket you open is closed somewhere in the program: (), [], {}.
  • For the purpose of this class use curly brackets –{}- at the beginning and the end of a class and a method (more about these in the next week).
  • Every open bracket has to be closed in the program!!!
  • public class HelloWorld { public static void main(String [] args) { System.out.println(“Hello World”); } }
  • public class HelloWorld { //beginning of the class body public static void main(String [] args) { System.out.println(“Hello World”); } } //end of the class body
  • public class HelloWorld { public static void main(String [] args) { //beginning of the method body System.out.println(“Hello World”); } //end of the method body }
  • public class HelloWorld public static void main(String [] args) { System.out.println(“Hello World”); } } Bracket missing Bracket expected
  • Enjoy finding the other errors.
  • Semicolons
  • You have to learn to love ; in Java. Every statement in Java ends with a ;.
  • public class HelloWorld { public static void main(String [] args) { System.out.println(“Hello World”); } }
  • Summary • Names are a single string. • Brackets always come in pairs. • Semicolons end a statement.
  • Thank you