|
|
||
| You are here: | ||
|
Big Picture/Little Picture The approach we are going to take requires you to to think about little pieces of the code at a time. You probably won't get the whole picture until you have had some practice writing and modifying the example programs. Some students hate this approach because they really need the big picture - if you are one of these, try the next page before returning here.
|
Also on this page: [ Common beginner's pitfalls | Using comments in code ] // A text field, a button, a label Notice the similar stucture here:
If we don't stick to this format (syntax) we will get an error (syntax error) and our code won't compile. Common errors when starting out are:
If you are studying alone and don't have an experienced teacher to help out these errors can be extremely frustrating. One possible solution is to cut and paste the code from this page into your editor or download the source files directly by right-button clicking the source link at the top. Another possible solution is to get in touch with IB Computing who can supply tailor-made courses just for you - but not for free :( Notice that comments (in blue in the code above) are of two types: Comments that span several lines can start with /* and end with */. Everything between them is a comment. Comments that start with // last until the end of the line and can even start part way through a line. // add places objects on the Applet surface in default layout We will use plenty of comments in our code to explain to humans what the code means. Sometimes comments are redundant (like the one we added to the example above) which is bad practice. Sometimes comments are left out altogether which is worse practice. We will say more on this later. Comments are ignored by the compiler. Related: [ Java Home | previous:PressMe.java | next:Intro to methods ] |
Examining Java code from the PressMe example. |
|
|
|||
|
Questions or problems related to this web site should be addressed to Richard Jones who asserts his right to be identified as the author and owner of these materials - unless otherwise indicated. Please feel free to use the material presented here and to create links to it for non-commercial purposes; an acknowledgement of the source is required by the Creative Commons licence. Use of materials from this site is conditional upon your having read the additional terms of use on the about page and the Creative Commons Licence. View privacy policy. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. © 2001 - 2009 Richard Jones, PO BOX 246, Cambridge, New Zealand; This page was last modified: May 31, 2009 |