Common errors
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Common errors

on

  • 2,382 views

 

Statistics

Views

Total Views
2,382
Views on SlideShare
77
Embed Views
2,305

Actions

Likes
0
Downloads
6
Comments
0

1 Embed 2,305

https://myasucourses.asu.edu 2305

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 Presentation Transcript

  • 1. Common Errors and Solutions CST200 – Week 1: Common Errors when Starting to write and compile Java Code Instructor: Andreea Molnar
  • 2. Outline • Disclaimer • Names • Brackets • Semicolons
  • 3. Error Category
  • 4. Names
  • 5. Names (e.g. class names, variable names, method names) are a single string!
  • 6. public class Hello World { } Is the class name Hello or World?
  • 7. public class Hello World { } After the first string –Hello – a bracket is expected.
  • 8. public class Hello World { }
  • 9. public class Hello World { }
  • 10. public class HelloWorld { } public class Hello { } public class World { }
  • 11. Keep in mind, it is not only class names, variable names and method names have to be composed of a single connected string.
  • 12. public class HelloWorld { public static void main(String [] args) { int Britteny Spears; } }
  • 13. public class HelloWorld { public static void main(String [] args) { int Britteny Spears; } } After the first string –Brittney – a ; is expected.
  • 14. public class HelloWorld { public static void main(String [] args) { int Britteny Spears; } }
  • 15. public class HelloWorld { public static void main(String [] args) { int BrittenySpears; int Britteny; int Spears; } }
  • 16. public class HelloWorld { public static void main(String [] args) { //this is the best int brittenySpears; int britteny; int spears; } }
  • 17. Brackets
  • 18. Every open bracket has to be closed in the program!!!
  • 19. As a rule of thumb check that every bracket you open is closed somewhere in the program: (), [], {}.
  • 20. 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).
  • 21. Every open bracket has to be closed in the program!!!
  • 22. public class HelloWorld { public static void main(String [] args) { System.out.println(“Hello World”); } }
  • 23. public class HelloWorld { //beginning of the class body public static void main(String [] args) { System.out.println(“Hello World”); } } //end of the class body
  • 24. public class HelloWorld { public static void main(String [] args) { //beginning of the method body System.out.println(“Hello World”); } //end of the method body }
  • 25. public class HelloWorld public static void main(String [] args) { System.out.println(“Hello World”); } } Bracket missing Bracket expected
  • 26. Enjoy finding the other errors.
  • 27. Semicolons
  • 28. You have to learn to love ; in Java. Every statement in Java ends with a ;.
  • 29. public class HelloWorld { public static void main(String [] args) { System.out.println(“Hello World”); } }
  • 30. Summary • Names are a single string. • Brackets always come in pairs. • Semicolons end a statement.
  • 31. Thank you