Your SlideShare is downloading. ×
  • Like
Common errors
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply
Published

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
2,465
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
6
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

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