java:defining_classes_in_java
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
java:defining_classes_in_java [2020/09/12 02:04] – mithat | java:defining_classes_in_java [2020/09/12 02:56] – [Where does the definition go?] mithat | ||
---|---|---|---|
Line 28: | Line 28: | ||
Here's a Java definition for a '' | Here's a Java definition for a '' | ||
- | <file java ClickerCounter.java> | + | <code java> |
public class ClickerCounter { | public class ClickerCounter { | ||
| | ||
Line 41: | Line 41: | ||
} | } | ||
} | } | ||
+ | </ | ||
+ | |||
+ | This definition states that an instance of a ClickerCounter will consist of a '' | ||
+ | |||
+ | ==== Where does the definition go? ==== | ||
+ | |||
+ | === The easy-for-beginners way === | ||
+ | If there' | ||
+ | |||
+ | <file java ClickerCounter.java> | ||
+ | tbd | ||
</ | </ | ||
+ | |||
+ | This isn't generally recommended though because very often you will write more than one custom class in your program. | ||
+ | |||
+ | === The better way === | ||
In Java, class definitions need to go in their own files, and the files need to be called the name of the class with the '' | In Java, class definitions need to go in their own files, and the files need to be called the name of the class with the '' |
java/defining_classes_in_java.txt · Last modified: 2020/09/14 01:38 by mithat