Java code is encapsulated in classes. The Java JShell command line environment lets you experiment and see what happens with arbitrary statements, but that code has to be wrapped in classes to be useful in a real application. Each class can have as many fields, methods, and other members that you need to accomplish your application’s tasks. Organizing your code is entirely up to you, however. In this video, learn how to move code from a main class to a custom class.
- [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 types of files.…I'll use the default, class.…
- Debugging Java code
- Handling exceptions
- Creating custom classes
- Working with inheritance
- Managing data collections
- Using Java packages and libraries
- Preparing a Java application for deployment
Skill Level Intermediate
1. Exception Handling and Debugging
2. Create Custom Classes
3. Work with Inheritance
4. Manage Data Collections
5. Use Java Packages and Libraries
Work with dates and times7m 12s
6. Prepare a Java Application for Deployment
Next steps1m 12s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.