Classes

A class is a programming language construct used to group related fields and methods. It contains constructors that are invoked to create objects from the class blueprint. Constructor declarations look like method declarations—except they use the name of the class and have no return type. Classes encapsulates all information and they are the blueprints for particular objects.

Name of the class has to be same as the program (file) name. Example. file name = Bob class name = Bob

Also include semicolon to show you're going to stop. ( Every statements ends in a semicolon). [ ], { } and ; shows certain stops.

__**Summary to the Makeup of a Class:**__ -**Fields**: (//instance variables//) Fields are the **data your class needs** such as **length, width, and/or how many of something**. Fields provide information about, and dynamic access to, a single field of a class or an interface. -**Methods**: (//commands//) Methods are **actions**. There are **Accessors which get info about your fields** and then there are **Mutators which change things**. Accessors can be referred to as the "get" method and Mutators can be referred to as the "set" method. A Java method is a series of statements that perform some repeated task. Instead of writing 10 lines of code we can put those ten lines in a method and just call it in one line. It is like a shortcut. -**Constructors**: (//new command//) Constructors are **methods that set all info to a default value when you create the object**.


 * Variables or Methods can be declared as private or public.**
 * Public**: A variable or method you //want users of your class to be able to access//.
 * Private**: A variable or method you want //no one else to use//.

Public members are acessible anywhere in the code; private members are accessible only within the class's costructors and member methods

code format="java" public class House { //fields private int numBaths; private FilledRect door; } code
 * __Fields__**- Data/Information


 * __Methods__**- Actions

- Accessors- get/__return__ information code format="java" public class Woman { //fields private int height, age, weight; //accessors public int getAge {   return age; } } code

- Mutators- changes things; modifies fields code format="java" public class Woman { private int age; public void setAge(int a) { age = a; } } code

Constructors- what makes a class turn into an object; sets and creates all data; may do something when you make the object - **new** calls an object-- **new** FilledRect(...);

code format="java" public class Eugene { //fields private int height, x, y; private boolean hasHair; //constructor public Eugene //Default- nothing sent in  { height = 10; x = 0; y = 0; hasHair = false; } public Eugene(int h, int xStart, int yStart, boolean hair) {   height = h;    x = xStart; y = yStart; hasHair = hair; } } code 1. When you declare a parameter to a method or a constructor, provide a name for that parameter. This name is used inside the method body to refer to the passed-in argument. 2. The name of a parameter must be unique and it can't be the same as the name of another parameter for the same method or constructor, and it can't be the name of a local variable inside the method or constructor. 3. A parameter can have the same name as one of the class's fields. If this is the case, the parameter is said to //shadow// the field. Shadowing fields can make your code difficult to read and is conventionally used only inside constructors and methods that set a particular field.
 * __Declaring Parameters__**-

An object that belongs to a particular class is also called an //instance// of that class, and the process of creating an object is called //instantation//.
 * __Instance:__**

java.applet - the applet context is an application that is responsible for loading and running applets. java.awt - contains all of the classes for creating user interfaces and for painting graphics and images. --java.awt.color - provides classes for color spaces. --java.awt.font - provides classes and interface relating to fonts. --java.awt.image - provides classes for creating and modifying images. java.util.jar - provides classes for reading and writing the JAR (Java ARchive) file format, which is based on the standard ZIP file format with an optional manifest file. java.util.random - which is used to generate a stream of pseudorandom numbers. java.util.scanner - a simple text scanner which can define primitive types and strings using regular expressions.
 * __Examples of Packages we use often:__**