> For the complete documentation index, see [llms.txt](https://hanfak.gitbook.io/workspace/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hanfak.gitbook.io/workspace/languages/java/intermediate/oop/objects.md).

# Objects

## What are they?

* An object is a specific instance of a class.

## Object creation

```java
Dog bubbles = new Dog(2, Sex.FEMALE, "Bubbles", 10.5);
Dog rocky = new Dog(5, Sex.MALE, "Rocky", 5.9);
```

* Bubbles and Rocky are objects, they have state as defined in the brackets, which can be used by the methods/behaviour.
* Now we have instances of the class, we can use their methods.
  * We can ask bubbles and rocky to run, and they will get the message (ie method) and perform that behaviour (run that method)

## Pass by reference

* <https://examples.javacodegeeks.com/java-pass-by-reference-vs-pass-by-value-example/>

### links

* <https://self-learning-java-tutorial.blogspot.co.uk/2014/02/object-creation-and-destruction.html>

## Object equality
