Welcome back to this lesson, Introduction to Java. This lesson is Java classes and objects. As we stated earlier, Java is an object-oriented programming language, which again, really means that the rules of object orientation are enforced by Java. Java allows developers to abstract and build or model real-world objects in the applications. Once built, the objects in the Java applications can interact with one another. Abstracted Java objects are called classes. Again, this constant of abstraction is actually modeling or simplifying real-world objects within a Java application, or modeling a real-world object. Java classes are again models of real-world objects. We model their behaviors and their properties. One way to begin understanding and building a Java application is actually begin to write out an architectural model of your object. In this case, we have an object car. The properties that we're concerned about, at least right now, are the cars make and the cars model. As you can begin to think, well, I can have several different types of cars all with different makes and all with different models. In our job application, we could have a car lot say with five cars on it, with a Ford, a Chevy, a Jeep. We would value make differently, and we would also value model differently. Then we would need some kind of behavior, and possibly, we can either talk to an architect or maybe we are architects, we can determine what kind of behavior or functions our object needs. We want to begin to model our objects and how they behave. We want to define some type of identity in the properties, and methods, and attributes that our objects will have. We want to understand how our objects will behave. Here with a model like this, this is usually simple enough that we can begin to get feedback from stakeholders or potential users, and we can also work with developers on this. Usually this architectural model here is simple enough that anybody can understand it. Again, this is going to be our example, we're going to model a car class and we're going to start small. We're going to start off with just a [inaudible] , properties, and functions or methods. Here we can take a look, as we begin to mature this architectural model, we can begin to identify the types of data that the properties will have. Java supports data types, what they call primitives and non-primitives. Primitives include data such as int, short, long, float, boolean, void, etc. These are very basic data types. Non-primitive data types are things as String, which could be a long set of characters and Date. There are some calculations behind String and Date, so they are what we call non-primitive. These can be mixed case and case does matter, so be careful. We can see here String is mixed case, but int is not, so we have to be careful. Notice Date as well is mixed case. We cannot have the String data type with a small S. These data types, the various data types have different minimum and maximum values, they have different lengths, different precisions. The different data types up here, int, the short or long, they actually manage our memory. We can actually manage our memory much more efficiently. So our job application can be more efficient and as fast as possible. Again, we want to obviously use the data types we need so we can take advantage of ways of making our job application as efficient as possible. We take a look at these charts here. We can see four particular category. For an integer, we can see the different integer types. We can see their sizes, we can see their minimum and maximum value and their precision. You can see some examples here. Long data type has a size of 64 bits, whereas a byte only has a size of eight. If we know, if we have a good idea of what our application needs, we can select the appropriate data type. We can see here also floating. We can see a double versus a float. We can see one is 64 bits, the other's 32, and then there are others such as void and boolean. Boolean would be true or false. We want to be able to pick out the data type that makes our application run as optimally as possible. We take a look here, some examples. We can see something like the character. Here we're looking at it, we see that it has a size of eight. But notice here it's saying b equals 65. Well, what does that mean? Well, actually, we can see here that the 65, in this case maps to the ASCII code, and 65 is actually an uppercase A. We can actually see it right here, with the character c is uppercase A. That's interesting. Functions. Functions are how our objects behave. They are blocks of code in our class that drive object behavior. Essentially they do something, they set a value, they update of value, they change a value, they can even make different colors appear on the screen if needed. A function can accept parameters. In this example here, we can see that parameters are going into this function. It can return a value. Accepting parameters and returning are optional. We can see here also this concept of visibility. Data types and functions have a certain visibility. Again, that will impact how our different objects interact and how they will share data. Private data and private functions means that the data in that object are only available to members of that class or members of that object. Public data means the data or functions are available not only to members of the class, but also members outside of that class or object. Once we have our architectural model to a point where it's mature enough that we can begin building the application, we can begin to move our model to Java code. Don't forget, most people in general can understand what we're doing here. That's why architectural models are so useful, and they can provide feedback. These should be built simple enough that everybody can understand them. There should be a certain structure that a developer is ready to move the model to Java code. If we take a look here, we're ready now to move our model to code. One of the places developers might start is right here with the attributes, their data types, and their visibility. We can see here, what's got the same attributes are being essentially coded into our Java application. We see here how they line up, it's almost one-to-one in this case. This has been Java classes and objects.