Creating a New Java Class
When NetBeans creates a new project, it sets up all the necessary files and folders and creates the main class. Figure A.3 shows the first class in your project, Spartacus.java
, open in the source editor.
Spartacus.java
is a bare-bones Java class that consists only of a main()
method. All the light gray lines in the class are comments that exist to explain the purpose and function of the class. Comments are ignored when the class is run.
To make the new class do something, add the following line of code on a new line right below the comment // TODO code application logic here
Get Sams Teach Yourself Java™ in 24 Hours, Sixth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.