Basic Java Language: Difference between revisions

wikademia>Katydidn't
Line 53: Line 53:
This is the bit that tells the Java compiler we are writing a new class, the only slightly notable thing about it is that it must be written in small letters. It is not <code>Class</code>!
This is the bit that tells the Java compiler we are writing a new class, the only slightly notable thing about it is that it must be written in small letters. It is not <code>Class</code>!
===Name===
===Name===
This is the name by which you will reference your class when you use it in your code, it can be called almost anything you want, containing numbers, letters and underscores. Though it must start and end with a letter. One thing to watch out for, is that like everything in Java it is case sensitive. This means that <code>Hello</code> is not the same as <code>hello</code>. You could, if you wanted have two different classes, one called <code>hello</code> and the other called <code>HeLlO</code>, however this might get confusing and so is strongly not recommended. In fact, in order to try and make things less confusing, there is a convention amoungst Java programmers that all words in a class name start with a capital letter, and the rest is lower case letters. ''eg.'' <code>public class VeryUseful</code> or <code>public class CompanyDepartment</code>
This is the name by which you will reference your class when you use it in your code, it can be called almost anything you want, containing numbers, letters and underscores, though it must start and end with a letter. One thing to watch out for, is that, like everything in Java, it is case sensitive. This means that <code>Hello</code> is not the same as <code>hello</code>. You could, if you wanted have two different classes, one called <code>hello</code> and the other called <code>HeLlO</code>, however this might get confusing and so is strongly not recommended. In fact, in order to try and make things less confusing, there is a convention amongst Java programmers that all words in a class name start with a capital letter, and the rest are lower case letters. ''eg.'' <code>public class VeryUseful</code> or <code>public class CompanyDepartment</code>


===Extends/Implements===
===Extends/Implements===