An open API service indexing awesome lists of open source software.

https://github.com/nojronatron/java-generics-practice

Follow documented methods to create and utilize generics in Java.
https://github.com/nojronatron/java-generics-practice

generic-types generics java object-oriented-programming

Last synced: about 1 year ago
JSON representation

Follow documented methods to create and utilize generics in Java.

Awesome Lists containing this project

README

          

# GenericsPractice Project

Following the Oracle Java Docs [Q and E](https://docs.oracle.com/javase/tutorial/java/generics/QandE/generics-questions.html), create code and tests that will validate learnings and answer ending Quiz questions.

## Takeaways

- An array is denoted by `[]` following a Type, which can be any primitive or Class: `Integer[] india = {1,2,3,}` is functionally similar to `int[] india = {1,2,3,}` but probably takes more memory storage.
- The Java class Arrays is a functional class that help work with Array types and Lists.
- The Java class Array has static methods used to create and access Java arrays.
- `List` is a Collection Interface that extends `Iterable`. Brackets `[]` array does not have these interface features.
- `ArrayList` implements `List` and is a fully instantiatable Class. Should not be confused with brackets `[]` arrays.
- Generic functions do *not* require a containing class to be generic! Use `public static void setMethod(){}` to set the method with a generic type placeholder.
- Leveraging wildcard `?` can be tricky due to inheritance, and there are situations where using it will cause problems during run time.

## Resources

Oracle's [Java Tutorials](https://docs.oracle.com/javase/tutorial/java/generics/index.html)

Baeldung: [Java Generics](https://www.baeldung.com/java-generics)

Baeldung: [Comparing Objects in Java](https://www.baeldung.com/java-comparing-objects)