From the course: Oracle Java Foundations
Java language - Java Tutorial
From the course: Oracle Java Foundations
Java language
(upbeat music) - [Joe] The Java language. The Java language is made up of three basic code structures, a class which codes the basic unit of your code and describes the data and logic of your program. A package which is an intermediate logical code aggregation, that's quite a mouthful. A package is zero or more classes, typically a group of classes that are logically related together. So for example, if I was creating an application for order entry, I would probably have an order entry package and I would have like an order class and I would have a product class and things like that. With Java9 we introduced the module. This is a high level physical code aggregation and allows you to override the lower level code aggregation of the package and choose explicitly what parts of your code you want to expose for reuse and people to access, and what parts you don't. In Java syntax, Java code is grouped into class. Here we see a class called employee. It has methods like for example, set salary and get name, which actually carry out code and do things and variables that store values. So for example, we have a variable called name, which is a string as we'll store names, and we have a get name method, and when that method is invoked, it returns the string, which is the name. We also have a set salary, which when we pass a value to it as a float, it will use that to set the salary value. Java includes exception handling, which allows you to interrupt the normal program execution flow. When a problem occurs. Here, for example, we're trying to read lines from a file and if the file, if we're not able to do so, maybe the file's gone or there's a problem with a file system, an exception would be thrown, and rather than the program crashing or having to write long, complicated logic to deal with this occurring, it's a much cleaner way to simply change the flow of execution, and we'll talk about this more when we talk about exception handling in the course itself. Most modern programming languages have some form of exception handling, C plus plus does, C Sharp does, PSQL does. All of these have the same basic idea that when an exception occurs, you branch out of where the exception occurs and goes to an exception handler where you then continue on to try to deal with the exception. Doing this allows you to decide what your program should do in the case of an error. Java exception handling allows you to write flexible code that can handle different types of adverse circumstances. When something undesirable or an error or a program occurs in your program execution, you can write code that can deal with that problem. (logo whooshing)