From the course: Java 8+ Essential Training: Objects and APIs
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Declare and use custom classes - Java Tutorial
From the course: Java 8+ Essential Training: Objects and APIs
Declare and use custom classes
- [Instructor] I've previously described how to organize code in custom methods. You can further organize your code by moving reusable methods into their own classes. Consider Java's math class. I want to look at the documentation for that class, and to get there, I'll simply type the word math and then with the cursor inside that class name, I'll press shift + F1. If you have your documentation configured for the Java Runtime, you'll get to this webpage. I'll go to the list of methods, and I'll see all these static methods that return various types and take various arguments. Here's how you can create your own classes that are essentially method libraries. I'll get rid of that bit of code that I just created, and then I'll go to my project window. I'll go to my package under the source directory, I'll right click it and choose new, Java class, and I'll create a new class named input helper. Under the kind list, you'll see that you can create classes, interfaces, enums, and other…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
About encapsulation3m 46s
-
Use the Java runtime classes4m 45s
-
(Locked)
Wrap code in static methods5m 56s
-
(Locked)
Declare and use custom classes4m 9s
-
(Locked)
Organize code with packages3m 46s
-
(Locked)
Create and use instance methods2m 27s
-
(Locked)
Manage state with instance variables7m 31s
-
(Locked)
Declare multiple constructor methods5m 2s
-
(Locked)
Use static fields as constants5m 51s
-
(Locked)
Declare and use enum types3m 44s
-
(Locked)
Organize code with nested types4m 15s
-
(Locked)
-
-
-
-
-